Function name: Chartohex ()
Function Description: Convert ASCII characters to 16 binary
Function Description:
Call Function:
Global variables:
Input: ASCII character
return: 16 binary
/////////////////////////////////////////////////////////////////////
unsigned char chartohex (unsigned char bhex) {
if ((bhex>=0) && (bhex<=9))
Bhex + = 0x30;
else if ((bhex>=10) && (bhex<=15))//Capital Letter
Bhex + = 0x37;
else Bhex = 0xFF;
return bhex;
}
/////////////////////////////////////////////////////////////////////
Function name: Hextochar ()
Function Description: Convert 16 binary to ASCII character
Function Description:
Call Function:
Global variables:
Input: 16 binary
Return: ASCII characters
/////////////////////////////////////////////////////////////////////
unsigned char hextochar (unsigned char bchar) {
if ((bchar>=0x30) && (bchar<=0x39))
Bchar-= 0x30;
else if ((bchar>=0x41) && (bchar<=0x46))//Capital Letter
Bchar-= 0x37;
else if ((bchar>=0x61) && (bchar<=0x66))//Small Letter
Bchar-= 0x57;
else Bchar = 0xFF;
return Bchar;
Word representable ASCII code, ASCII transcoding characterPublicStaticIntASC (StringCharacter
{
If(character. Length==1)
{
System.Text.ASCIIEncoding asciiencoding=NewSystem.Text.ASCIIEncoding ();
IntIntasciicode=(Int) asciiencoding.getbytes (character) [0];
Return(Intasciicode);
}
Else
{
ThrowNewException ("Character is not valid.");
}
}
ASCII transcoding:
PublicStaticStringCHR (IntAsciicode)
{
If(Asciicode>=0&&Asciicode<=255)
{
System.Text.ASCIIEncoding asciiencoding=NewSystem.Text.ASCIIEncoding ();
Byte[] ByteArray=NewByte[]{ (Byte) Asciicode};
StringStrcharacter= asciiencoding.getstring (ByteArray);
return ( Strcharacter);
}
else
{
throw new exception ( "ascii code is not valid. ");
}
}&NBSP;
Example code for a function that turns characters into ASCII values in JS
<script>
Str= "A";
Code = str.charcodeat ();
str2 = String.fromCharCode (code);
STR3 = String.fromCharCode (0x60+26);d ocument.write (code+ ' <br/> ');
document.write (str2+ ' <br/> ');
document.write (STR3);
</script>
Convert a string to an ASCII code
Format: ASC (x)
Function: Returns the ASCII code of the first character in the string x.
Description
X is a string data, and the function value returns one.
For example:
The value of x=asc ' 0 ' x is
X=asc' ABC ' x has a value of
Convert ASCII code to characters
Format: CHR (x)
Function: Converts the ASCII value to the corresponding character.
Description
X is an ASCII code value, and the function value returns a character.
For example:
The value of X=CHR ' x is the character ' B '
Toascii converting characters to ASCII code
Toascii converting characters to ASCII code
Function prototype: Inttoascii (INTC); header file: Ncludectype.h is the standard function: function function: convert c to the corresponding ASCII code. Return value: Returns the converted value, which is the converted ASCII code. Apply the TOASCII function to convert an integer number to the corresponding ASCII code. #includectype. Hmain () ints[]={l,2,3,4,5,6};inti;for (i=0;i6;i++) {printf (-%d-,s[i]);p Utchar (Toascii (s[i])); Routine Description: ( 1) First deposit 146 integer numbers in an integer array and display them on the terminal screen. (2) cyclically converts each number in the array to its corresponding ASCII code and displays it as a character on the terminal screen. The result of this routine is: 123456.
C-language character conversion ASCII code