Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying French characters?
#5
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


Reply


Messages In This Thread
Displaying French characters? - by bplus - 04-30-2025, 07:01 PM
RE: Displaying French characters? - by Petr - 04-30-2025, 08:07 PM
RE: Displaying French characters? - by Alex-Ubik - 05-06-2025, 02:45 PM
RE: Displaying French characters? - by bplus - 04-30-2025, 08:49 PM
RE: Displaying French characters? - by Petr - 05-06-2025, 04:58 PM
RE: Displaying French characters? - by Alex-Ubik - 05-06-2025, 05:33 PM
RE: Displaying French characters? - by Petr - 05-06-2025, 06:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  printing characters > chr$(127) madscijr 18 2,147 03-11-2025, 07:33 PM
Last Post: madscijr
  Need some help getting characters to follow each other correctly Cobalt 6 1,057 11-22-2024, 01:19 AM
Last Post: Cobalt
  Error displaying 256 color PCX image program? macalwen 8 1,657 07-05-2024, 01:39 PM
Last Post: SMcNeill
  control characters in Change dialog box digitalmouse 10 1,849 05-09-2024, 02:17 AM
Last Post: digitalmouse
  _TITLE and extended ASCII characters. Pete 37 6,448 11-16-2022, 01:40 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: