Skip to content

CharToString

CharToString

Converting a symbol code into a one-character string.

string  CharToString(
   uchar  char_code      // numeric code of symbol
   );

Parameters

char_code

[in] Code of ANSI symbol.

Return Value

String with a ANSI symbol.

Example:

string ExtStrArray[224];

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- in the loop from the symbol code 32 (space) to 255(UCHAR_MAX),
//--- fill the array with symbol codes converted to a string in accordance with the current code page
   for(int i=32; i<=UCHAR_MAX; i++)
      ExtStrArray[i-32]=CharToString((uchar)i);

//--- print the header and the symbol table in the journal
   Print("Table of symbols:");
   ArrayPrint(ExtStrArray,_Digits," | ");
   /*
   result:
   Table of symbols:
   [  0] " " | "!" | """ | "#" | "$" | "%" | "&" | "'" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8"
   [ 25] "9" | ":" | ";" | "<" | "=" | ">" | "?" | "@" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q"
   [ 50] "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "[" | "\" | "]" | "^" | "_" | "`" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j"
   [ 75] "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "{" | "|" | "}" | "~" | "" | "&#1026;" | "&#1027;" | "‚" | "&#1107;"
   [100] "„" | "…" | "†" | "‡" | "€" | "‰" | "&#1033;" | "‹" | "&#1034;" | "&#1036;" | "&#1035;" | "&#1039;" | "&#1106;" | "‘" | "’" | "“" | "”" | "•" | "–" | "—" | "&#152;" | "™" | "&#1113;" | "›" | "&#1114;"
   [125] "&#1116;" | "&#1115;" | "&#1119;" | " " | "&#1038;" | "&#1118;" | "&#1032;" | "&curren;" | "&#1168;" | "&brvbar;" | "&sect;" | "&#1025;" | "&copy;" | "&#1028;" | "&laquo;" | "&not;" | "&shy;" | "&reg;" | "&#1031;" | "&deg;" | "&plusmn;" | "&#1030;" | "&#1110;" | "&#1169;" | "&micro;"
   [150] "&para;" | "&middot;" | "&#1105;" | "&#8470;" | "&#1108;" | "&raquo;" | "&#1112;" | "&#1029;" | "&#1109;" | "&#1111;" | "&#1040;" | "&#1041;" | "&#1042;" | "&#1043;" | "&#1044;" | "&#1045;" | "&#1046;" | "&#1047;" | "&#1048;" | "&#1049;" | "&#1050;" | "&#1051;" | "&#1052;" | "&#1053;" | "&#1054;"
   [175] "&#1055;" | "&#1056;" | "&#1057;" | "&#1058;" | "&#1059;" | "&#1060;" | "&#1061;" | "&#1062;" | "&#1063;" | "&#1064;" | "&#1065;" | "&#1066;" | "&#1067;" | "&#1068;" | "&#1069;" | "&#1070;" | "&#1071;" | "&#1072;" | "&#1073;" | "&#1074;" | "&#1075;" | "&#1076;" | "&#1077;" | "&#1078;" | "&#1079;"
   [200] "&#1080;" | "&#1081;" | "&#1082;" | "&#1083;" | "&#1084;" | "&#1085;" | "&#1086;" | "&#1087;" | "&#1088;" | "&#1089;" | "&#1090;" | "&#1091;" | "&#1092;" | "&#1093;" | "&#1094;" | "&#1095;" | "&#1096;" | "&#1097;" | "&#1098;" | "&#1099;" | "&#1100;" | "&#1101;" | "&#1102;" | "&#1103;"
   */
  }

See also

StringToCharArray, ShortToString, StringGetCharacter

Last updated on