Posts: 4,698
Threads: 222
Joined: Apr 2022
Reputation:
322
Someone is asking about displaying French characters, here:
https://qb64.boards.net/thread/416/displ...characters
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 513
Threads: 65
Joined: May 2022
Reputation:
83
04-30-2025, 08:07 PM
(This post was last modified: 04-30-2025, 08:08 PM by Petr.)
Here it is, is used Google translator, I only know "good morning" in French
Program create french text on the screen and also try create french named file and then test it if it exist and write message in french to screen. It works fine in my system (Win10)
Code: (Select All)
Screen 0
_Font _LoadFont("C:\windows\fonts\cour.ttf", 20, "MONOSPACE")
Restore Microsoft_windows_cp1252:
For ASCIIcode = 128 To 255
Read unicode
_MapUnicode unicode To ASCIIcode
Next
Text$ = "Il s'agit d'un test de texte en français."
Print Text$
file$ = "DÉPOSER"
ff = FreeFile
Open file$ For Binary As ff
Close ff
If _FileExists(file$) Then Print "Fichier avec nom français créé": Kill file$ Else Print "Fichier avec nom français non créé"
End
Microsoft_windows_cp1252:
Data 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0
Data 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376
Data 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
Data 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
Data 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
Data 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
Data 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
Data 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
Posts: 4,698
Threads: 222
Joined: Apr 2022
Reputation:
322
+1 Thank you @Petr I will pass on the link.
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 2
Threads: 0
Joined: May 2025
Reputation:
0
(04-30-2025, 08:07 PM)Petr Wrote: Here it is, is used Google translator, I only know "good morning" in French 
Program create french text on the screen and also try create french named file and then test it if it exist and write message in french to screen. It works fine in my system (Win10) ...
Hi Petr, I'm the person who asked the question on the QB64 site.
I wanted to thank you for your help earlier, but I had some trouble registering here...
Your code works perfectly on my Win7. So thank you!
But since we're never satisfied, I realize now that I would have liked to use in my program those fancy little input boxes  we used to create in basic in the 80's using the single and double lines around the characters 176 to 218. (╚══╩═ ... ──┤an so on)
Do you think it's possible to use a code similar to the one you developed above to go back to the classic ASCII table and then call one routine or the other with a CALL or a GOSUB as required? And how ?
Sorry if the question sounds simplistic, but I've learned coding in the 80s using GWBasic, under DOS. Loooong time ago !
Alex
Posts: 513
Threads: 65
Joined: May 2022
Reputation:
83
05-06-2025, 04:58 PM
(This post was last modified: 05-06-2025, 05:07 PM by Petr.)
Hi, glad it help. I solved this in the past too, for Czech. What you suggest is certainly possible, but you will have to watch the unicode page that you set before printing the text to the screen.
I am adding a program that shows how you can use multiple code pages at once. That is why the text in French is intentionally printed "wrong" this time - with the American MS-DOS code page and then the code page is thrown back to 1252 so that it supports French. Interesting question, this is my first time doing this.
While writing the program I found that it is necessary to use a graphics screen to be able to display different types of encoding. If you use Screen 0, only the first type (1252) is set and then it does not change. I assume that this is intentional, because the text screen 0 can only hold 256 characters, while the graphics screen approaches the image differently and will draw anything.
The numbers for the DATA blocks are obtained from the help: In the IDE, press Shift+F1 together, click on Kws_Alphab, then write: "Mapunicode" click on _MapUnicode (statement), scroll down in the help window and click on Code Pages there. That will lead you to the supported encoding types. Maybe someone will add a link directly to the QB64PE wiki here?
Code: (Select All)
Screen _NewImage(1024, 768, 256)
_Font _LoadFont("C:\windows\fonts\cour.ttf", 20, "MONOSPACE")
SetUnicode 1252
'Text$ = "Il s'agit d'un test de texte en français."
Text$ = "Il s'agit d'un test de texte en français. ÜÝŢßŰ ÜŰ"
Print Text$
SetUnicode 437 'in this case is text printed bad
Print Text$
SetUnicode 1252
file$ = "DÉPOSER"
ff = FreeFile
Open file$ For Binary As ff
Close ff
If _FileExists(file$) Then Print "Fichier avec nom français créé": Kill file$ Else Print "Fichier avec nom français non créé"
End
Sub SetUnicode (CodePage As Integer)
Select Case CodePage
Case 1252
Restore Microsoft_windows_cp1252:
For ASCIIcode = 128 To 255
Read unicode
_MapUnicode unicode To ASCIIcode
Next
Microsoft_windows_cp1252:
Data 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0
Data 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376
Data 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
Data 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
Data 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
Data 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
Data 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
Data 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
Case 437
Restore Microsoft_pc_cp437
For ASCIIcode = 128 To 255
Read unicode
_MapUnicode unicode To ASCIIcode
Next
Microsoft_pc_cp437:
Data 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
Data 201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402
Data 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187
Data 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
Data 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
Data 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
Data 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
Data 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
End Select
End Sub
Posts: 2
Threads: 0
Joined: May 2025
Reputation:
0
05-06-2025, 05:33 PM
(This post was last modified: 05-06-2025, 05:38 PM by Alex-Ubik.)
Wow ! As I told last time to bplus on "his" own forum : "you're fast!"
Thank you for your advice and the code. I should come up with something good with this.
It may take a little time but it's all to the good, it's making me slowly revise all my knowledge of Basic. (Sometimes I realize that I've forgotten essential things, even in the syntax that I used to know well).
Thanks again!
And btw I went on your Youtube channel: nice Tetris!
Posts: 513
Threads: 65
Joined: May 2022
Reputation:
83
Thank you, it's been a long time since I tried to write my own version of Tetris (clone), it doesn't respect the rules (number of columns and shapes and rotation options) like the original - but in principle it works correctly.
If you need anything else, feel free to contact me. And - welcome to this forum!
|