Posts: 54
Threads: 12
Joined: Apr 2022
Reputation:
2
12-03-2025, 10:19 AM
(This post was last modified: 12-03-2025, 10:21 AM by Ikerkaz.)
Hi to all !!!
I have a little program that reads the contents of a folder (with _FILES$ function), then stores them in a string array, and finally it prints all the array on screen.
My problem is that I have accents and special chars on names (I am from Spain, we have Ñs and á é í ó ú).
I tried with _UPrintString (x, y), NAME(i), , 8,font ... but it only works with standard file names with no accents 
If the name has no special chars it shows the name correctly, but with accents or Ñs it shows an empty string.
What am I doing wrong?
Thank U very much !!!
10 PRINT "Hola!  "
20 GOTO 10
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
First question: Have you loaded a font with the Unicode characters in it with _LoadFont and _Font?
Posts: 54
Threads: 12
Joined: Apr 2022
Reputation:
2
Yes, I am using Arial Narrow
Font = _LoadFont("C:\WINDOWS\FONTS\ARIALNB.TTF", 20)
10 PRINT "Hola!  "
20 GOTO 10
Posts: 513
Threads: 65
Joined: May 2022
Reputation:
83
Use _MapUnicode with correct data block for Spain. Press Shift +F1 in IDE then alphabetical/ _mapunicode and search your code page data block and example program.
Posts: 54
Threads: 12
Joined: Apr 2022
Reputation:
2
I tested this program:
Code: (Select All)
Screen 0
Dim MyFont As Long
MyFont = _LoadFont("C:\WINDOWS\FONTS\ARIALNB.TTF", 40) 'select monospace font
Restore Microsoft_pc_cp850 'or restore single DATA field w/o field name
For ascii = 128 To 255 'assign unicode values to ascii 128 to 255 only
Read unicode&
If unicode& = 0 Then unicode& = 9744 'make undefined characters look like a box
_MapUnicode unicode& To ascii 'replace ascii with unicode value
Next
Screen _NewImage(1024, 768, 32)
_PrintMode _KeepBackground
_Font MyFont
For code = 128 To 255
Print code; Chr$(code); 'display unicode characters
Next
End
Microsoft_pc_cp850:
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,248,163,216,215,402
Data 225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187
Data 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
Data 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
Data 240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600
Data 211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180
Data 173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
It shows correctly the special chars, but I don't know how to adapt it to my program
I tried to _MAPUNICODE before writing on screen my file names, but it is not working, it is showing blank strings (if the string has special chars)
10 PRINT "Hola!  "
20 GOTO 10
Posts: 54
Threads: 12
Joined: Apr 2022
Reputation:
2
12-03-2025, 12:32 PM
(This post was last modified: 12-03-2025, 12:33 PM by Ikerkaz.)
I've reduced my program to the bare minimum, in order to try several printing options:
Code: (Select All)
Option _Explicit
Dim As Integer Ascii, Maximo
Dim As String Archivo, Ruta
Dim As Long Unicode, Fuente
Ruta = "C:\My Program Files\Externo virtual\Test"
Screen _NewImage(640, 480, 32)
Fuente = _LoadFont("C:\WINDOWS\FONTS\ARIALNB.TTF", 40)
Restore Microsoft_pc_cp850 'or restore single DATA field w/o field name
For Ascii = 128 To 255 'assign unicode values to ascii 128 to 255 only
Read Unicode&
If Unicode& = 0 Then Unicode& = 9744 'make undefined characters look like a box
_MapUnicode Unicode& To Ascii 'replace ascii with unicode value
Next
Maximo = 1
Archivo = _Files$(Ruta + "\*.*")
_Font Fuente
Cls
Color _RGB(255, 255, 255)
Do While Archivo <> ""
Dim puntoPos As Long
puntoPos = InStr(Archivo, ".")
If puntoPos > 0 Then
Dim ext As String
ext = LCase$(Mid$(Archivo, puntoPos + 1))
If ext = "mp4" Or ext = "avi" Or ext = "mkv" Or ext = "mov" Or ext = "wmv" Or ext = "flv" Then
Maximo = Maximo + 1
_UPrintString (0, Maximo * 20), Archivo, , 0, Fuente
_UPrintString (0, Maximo * 40), Archivo, , 8, Fuente
_PrintString (0, Maximo * 60), Archivo
Print Archivo
End If
End If
Archivo = _Files$
_Display
Loop
End
Microsoft_pc_cp850:
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,248,163,216,215,402
Data 225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187
Data 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
Data 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
Data 240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600
Data 211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180
Data 173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
This is my result:
But this is the original file name:
10 PRINT "Hola!  "
20 GOTO 10
Posts: 53
Threads: 11
Joined: Apr 2022
Reputation:
74
Try using the DATA values for codepage Win-1252 instead of Pc-850.
https://qb64phoenix.com/qb64wiki/index.p...es#CP_1252
Posts: 54
Threads: 12
Joined: Apr 2022
Reputation:
2
10 PRINT "Hola!  "
20 GOTO 10
Posts: 522
Threads: 55
Joined: Jul 2022
Reputation:
48
yeah in the years this question about portability of screen output and keyboard or file input runs over and over.
Maybe it must be showed into FAQ of wiki so the solution is visible for all new users...
I remember that at the time of QB64 SDL I got the help of Clippy and then from another Czech user(sorry my bad memory doesn't let me remember his name) that showed me how to performing the task by using _mapunicode.
Some years after I collaborated with Steve to map keyboard input with _deviceinput(1). I got and published in that thread the set for Italian and West Europe code set.
|