Author Topic: code ASCII  (Read 4202 times)

0 Members and 1 Guest are viewing this topic.

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
code ASCII
« on: September 02, 2021, 02:51:33 pm »
Hello.
Maybe someone will look at the code. Well, it shows me two letters instead of one under the CHR $ code (136).
Thanks

Code: QB64: [Select]
  1. _TITLE "Calendarium"
  2. SCREEN _NEWIMAGE(130, 45, 0)
  3. IF X < 1400 THEN Fontsize = 16 ELSE Fontsize = 18
  4. _FONT _LOADFONT("C:\Windows\Fonts\lucon.ttf", Fontsize, "MONOSPACE")
  5. RESTORE Microsoft_pc_cp852
  6. FOR ascii = 128 TO 255
  7.     READ unicode&
  8.     IF unicode& = 0 THEN unicode& = 9744
  9.     _MAPUNICODE unicode& TO ascii
  10. COLOR 10, 1
  11. PRINT " "
  12. PRINT " "
  13. PRINT "                                            ----------------------------------------------------"
  14. PRINT "                                              Program do obliczania element" + CHR$(162) + "w odcinka ko" + CHR$(136) + "ˆowego"
  15. PRINT "                                            ----------------------------------------------------"
  16. PRINT " "
  17. Microsoft_pc_cp852:
  18. DATA 199,252,233,226,228,367,263,231,322,235,336,337,238,377,196,262
  19. DATA 201,313,314,244,246,317,318,346,347,214,220,356,357,321,215,269
  20. DATA 225,237,243,250,260,261,381,382,280,281,172,378,268,351,171,187
  21. DATA 9617,9618,9619,9474,9508,193,194,282,350,9571,9553,9559,9565,379,380,9488
  22. DATA 9492,9524,9516,9500,9472,9532,258,259,9562,9556,9577,9574,9568,9552,9580,164
  23. DATA 273,272,270,203,271,327,205,206,283,9496,9484,9608,9604,354,366,9600
  24. DATA 211,223,212,323,324,328,352,353,340,218,341,368,253,221,355,180
  25. DATA 173,733,731,711,728,167,247,184,176,168,729,369,344,345,9632,160
  26. SUB PrintIt (a$)
  27.     PrintIt a$
« Last Edit: September 02, 2021, 03:42:09 pm by odin »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: code ASCII
« Reply #1 on: September 02, 2021, 03:11:58 pm »
Now its writed in Polish correctly. You can writining directly your nationals characters usin Polish keyboard to IDE, in IDE is then this text not displayed correctly, BUT with _MAPUNICODE is then your Polish text displayed correctly in program.

This is your problem: You write to IDE +" ?? owego " and ?? is your polish unicode character, wrongly displayed in IDE but correctly in program as second character.

 You can not using this way for harddrive paths. Greetings from Czech republic :)


Code: QB64: [Select]
  1. _TITLE "Calendarium"
  2. SCREEN _NEWIMAGE(130, 45, 0)
  3. IF X < 1400 THEN Fontsize = 16 ELSE Fontsize = 18
  4. _FONT _LOADFONT("C:\Windows\Fonts\lucon.ttf", Fontsize, "MONOSPACE")
  5. RESTORE Microsoft_pc_cp852
  6. FOR ascii = 128 TO 255
  7.     READ unicode&
  8.     IF unicode& = 0 THEN unicode& = 9744
  9.     _MAPUNICODE unicode& TO ascii
  10. COLOR 10, 1
  11. PRINT " "
  12. PRINT " "
  13. PRINT "                                            ----------------------------------------------------"
  14. PRINT "                                              Program do obliczania element" + CHR$(162) + "w odcinka ko" + CHR$(136) + "owego"
  15. PRINT "                                            ----------------------------------------------------"
  16. PRINT " "
  17. Microsoft_pc_cp852:
  18. DATA 199,252,233,226,228,367,263,231,322,235,336,337,238,377,196,262
  19. DATA 201,313,314,244,246,317,318,346,347,214,220,356,357,321,215,269
  20. DATA 225,237,243,250,260,261,381,382,280,281,172,378,268,351,171,187
  21. DATA 9617,9618,9619,9474,9508,193,194,282,350,9571,9553,9559,9565,379,380,9488
  22. DATA 9492,9524,9516,9500,9472,9532,258,259,9562,9556,9577,9574,9568,9552,9580,164
  23. DATA 273,272,270,203,271,327,205,206,283,9496,9484,9608,9604,354,366,9600
  24. DATA 211,223,212,323,324,328,352,353,340,218,341,368,253,221,355,180
  25. DATA 173,733,731,711,728,167,247,184,176,168,729,369,344,345,9632,160
  26. SUB PrintIt (a$)
  27.     PrintIt a$
  28.  
  29.  

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
Re: code ASCII
« Reply #2 on: September 02, 2021, 03:34:11 pm »
Děkuji. Nyní se zobrazuje dobře. Co jste ale v kódu změnili, nemohu zjistit.

> Thank you. It is now showing well. But I can't find out what you've changed in the code.
« Last Edit: September 02, 2021, 03:40:40 pm by odin »

Offline odin

  • Administrator
  • Newbie
  • Posts: 92
  • I am.
    • View Profile
Re: code ASCII
« Reply #3 on: September 02, 2021, 03:41:55 pm »
Please use [code=qb64][/code] around your code. And let's keep it in English, please.

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
Re: code ASCII
« Reply #4 on: September 02, 2021, 03:44:58 pm »
Thank you. What you've changed that now displays properly. I can't see myself.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: code ASCII
« Reply #5 on: September 02, 2021, 04:14:46 pm »
The change is only on the line 20 in my source code, in your text

Code: [Select]
  Program do obliczania element" + CHR$(162) + "w odcinka ko" + CHR$(136) + "owego"

while your original text was

Code: [Select]
Program do obliczania element" + CHR$(162) + "w odcinka ko" + CHR$(136) + "ˆowego"

see you character ^ before word "owego"? This was problem.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: code ASCII
« Reply #6 on: September 02, 2021, 04:15:29 pm »
Thank you. What you've changed that now displays properly. I can't see myself.

Difference is only a ? removed:
  [ You are not allowed to view this attachment ]  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: code ASCII
« Reply #7 on: September 02, 2021, 05:01:46 pm »
Ryster, if you use Windows CP 1250 encoding (we have both the same, I just had to add a Polish keyboard to the system for the following example) then you can type it into the IDE in Polish directly. Here's proof that it works.

for Odin:
Because the following source code contains unicode characters, CODE must be used without formatting.


Code: [Select]
_TITLE "Calendarium"
SCREEN _NEWIMAGE(130, 45, 0)
_SCREENMOVE _MIDDLE
X = _DESKTOPWIDTH
IF X < 1400 THEN Fontsize = 16 ELSE Fontsize = 18
_FONT _LOADFONT("C:\Windows\Fonts\lucon.ttf", Fontsize, "MONOSPACE")
_DELAY .2
_SCREENMOVE _MIDDLE
RESTORE Microsoft_windows_cp1250 'central europe languages PL, CZ, SK, HU...
FOR ascii = 128 TO 255
    READ unicode&
    IF unicode& = 0 THEN unicode& = 9744
    _MAPUNICODE unicode& TO ascii
NEXT
COLOR 10, 1
CLS
PRINT " "
PRINT " "
PRINT "                                            ----------------------------------------------------"
PRINT "                                              Program do obliczania elementów odcinka kołowego "
PRINT "                                            ----------------------------------------------------"
PRINT "pokus o zobrazení česky psaného textu s použitím polského kodování. "






Microsoft_windows_cp1250:
DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,352,8249,346,356,381,377
DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,353,8250,347,357,382,378
DATA 160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379
DATA 176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380
DATA 340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270
DATA 272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223
DATA 341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271
DATA 273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729
END
SUB PrintIt (a$)
    PrintIt a$
END SUB


Output contains czech and polish characters, all displayed correctly.

  [ You are not allowed to view this attachment ]  


Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: code ASCII
« Reply #8 on: September 02, 2021, 05:12:58 pm »
for others, I'm just adding a sample of what it actually looks like in the IDE

  [ You are not allowed to view this attachment ]  


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: code ASCII
« Reply #9 on: September 02, 2021, 05:19:34 pm »
for others, I'm just adding a sample of what it actually looks like in the IDE

  [ You are not allowed to view this attachment ]

Can’t you set the IDE to code page 1250 as well, in the options?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: code ASCII
« Reply #10 on: September 02, 2021, 05:32:44 pm »
@SMcNeill Hi. Yeah, right, I can. But the default setting looks best, then it's the clearest. That image is by default. This is by no means an attempt to defame the IDE.

You know, when I set it to my encoding, it looks like this:

(note the decay of characters along the edges of the IDE and in the menu) - but this is quite clear, it is due to ASCII transcoding.

  [ You are not allowed to view this attachment ]  

Offline Ryster

  • Newbie
  • Posts: 77
    • View Profile
Re: code ASCII
« Reply #11 on: September 03, 2021, 09:44:39 am »
I can't believe it how could I have missed it. I need to change my glasses. Thank you for explaining the visual problem.

Thank You: Piotr (neighbor), bplus, SMcNeill.
Regards