QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: TempodiBasic on April 26, 2021, 10:17:28 am

Title: unicode of character:how to do ?
Post by: TempodiBasic on April 26, 2021, 10:17:28 am
Hi boys and girls of QB64

please help me, how can I get the unicode value of a character taken from a string?

Thank you for feedbacks
Title: Re: unicode of character:how to do ?
Post by: SMcNeill on April 26, 2021, 12:10:32 pm
Are you wanting to print the character?  If so, take a look at QPrint: https://www.qb64.org/forum/index.php?topic=3676.msg130229#msg130229

Title: Re: unicode of character:how to do ?
Post by: TempodiBasic on April 26, 2021, 01:57:11 pm
Hi Steve
thanks for the help
I was searching a way to get the UNICODE value related a character. Moreover I dunno if  all character set used cover all UNICODE values.
In other words if I set a string like "thisisthetext"  can I get back the unicode value of each character?  Anymore can I set a string "qw314ìòràfì" that cover all the unicode values?

this 2 wikipages founded following your post have given me good help, but I'm still solving to cover all unicode values.
http://www.qb64.org/wiki/MAPUNICODE (http://www.qb64.org/wiki/MAPUNICODE)  http://www.qb64.org/wiki/Unicode (http://www.qb64.org/wiki/Unicode)

Thanks again

PS this is the cause of my search http://rosettacode.org/wiki/Palindrome_detection (http://rosettacode.org/wiki/Palindrome_detection)
Quote
For extra credit:

Support Unicode characters.
Write a second function (possibly as a wrapper to the first) which detects inexact palindromes, i.e. phrases that are palindromes if white-space and punctuation is ignored and case-insensitive comparison is used.
Title: Re: unicode of character:how to do ?
Post by: moises1953 on May 18, 2021, 04:57:59 am
Usually the character codes in Windows are 8 bits, and therefore 256 different characters, of which the first 128 correspond to the 7-bit ASCII used in telecommunications since the time of the teletype, however the last 128 may vary according to the adaptation to the language performed using code pages. In western countries the code page is 1252.
QB64 does a character code mapping to be compatible with the original MSDOS page, known as 437, but that mapping can be changed with the _MAPUNICODE instruction.
Additionally, the _MAPUNICODE function allows obtaining the unicode code of each character in UTF32 format, which is the internal Windows format.
With this simple program you can see all:
Code: QB64: [Select]
  1. DEFLNG H-P
  2. CONST Apl = "Maped Unicodes"
  3.  
  4. SCREEN NEWIMAGE(800, 600, 256)
  5. TITLE Apl
  6. CONTROLCHR OFF
  7. 'OPEN "MapedUnicodes.txt" FOR OUTPUT AS #1
  8. line$ = ""
  9. FOR i = 0 TO 255 STEP 16
  10.   PRINT USING "###:"; i;
  11.   FOR j = i TO i + 15
  12.     map = MAPUNICODE(j)
  13.     IF j = i THEN
  14.       line$ = STR$(map)
  15.     ELSE
  16.       line$ = line$ + "," + STR$(map)
  17.     END IF
  18.     PRINT USING "#####"; map;
  19.  
  20.     READ kunicode
  21.     IF kunicode - map THEN PRINT "*"; ELSE PRINT " ";
  22.   NEXT j
  23.   '  PRINT #1, line$
  24. 'CLOSE #1
  25. FOR i = 0 TO 255 STEP 16
  26.   PRINT USING "###:"; i;
  27.   FOR j = i TO i + 15
  28.     PRINT CHR$(j);
  29.   NEXT j
  30. PRINT CHR$(128)
  31.  
  32. 'unicodes -> CP437
  33. DATA 32,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788
  34. DATA 9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660
  35. DATA 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47
  36. DATA 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
  37. DATA 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79
  38. DATA 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
  39. DATA 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111
  40. DATA 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,8962
  41. DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  42. DATA 201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402
  43. DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187
  44. DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  45. DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  46. DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  47. DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  48. DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,32
  49.