Difference between revisions of "MAPUNICODE (function)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 10: Line 10:
 
* Returns can be used to verify or catalog the present Unicode mapping.
 
* Returns can be used to verify or catalog the present Unicode mapping.
 
* The function will return Unicode values for the control characters, CHR$(127) and extended characters without mapping them first.
 
* The function will return Unicode values for the control characters, CHR$(127) and extended characters without mapping them first.
 +
 +
 +
''Example:'' Store function return values in an array for ASCII codes 0 to 255 to restore them later.
 +
{{CodeStart}}
 +
{{Cl|DIM}} Array&(255)
 +
{{Cl|SCREEN (statement)|SCREEN}} 0
 +
{{Cl|_FONT}} {{Cl|_LOADFONT}}("C:\Windows\Fonts\Cour.ttf", 20, "MONOSPACE") 'select monospace font
 +
 +
{{Cl|FOR...NEXT|FOR}} code = 1 {{Cl|TO}} 255
 +
Array&(code) = {{Cl|_MAPUNICODE (function)|_MAPUNICODE}}(code)  'read Unicode values
 +
{{Cl|PRINT}} Array&(code);                  'display values in demo
 +
{{Cl|NEXT}}
 +
'rest of program
 +
{{Cl|END}}
 +
{{CodeEnd}}
  
  

Revision as of 03:57, 24 October 2010

The _MAPUNICODE function returns the Unicode(UTF32) code point value of a mapped ASCII character code.


Syntax: UTFvalue& = _MAPUNICODE(Ascii_code%)


  • The UTF32 values have 4 byte encoding so the return variable should be LONG.
  • The Ascii_code can be any INTEGER value from 0 to 255.
  • Returns can be used to verify or catalog the present Unicode mapping.
  • The function will return Unicode values for the control characters, CHR$(127) and extended characters without mapping them first.


Example: Store function return values in an array for ASCII codes 0 to 255 to restore them later.

DIM Array&(255) SCREEN 0 _FONT _LOADFONT("C:\Windows\Fonts\Cour.ttf", 20, "MONOSPACE") 'select monospace font FOR code = 1 TO 255 Array&(code) = _MAPUNICODE(code) 'read Unicode values PRINT Array&(code); 'display values in demo NEXT 'rest of program END


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page