MariaDB /MySQL returns ? instead of ë In PureBasic

Just starting out? Need help? Post your questions and find answers here.
User avatar
RBart
User
User
Posts: 33
Joined: Sun May 04, 2025 11:18 am

MariaDB /MySQL returns ? instead of ë In PureBasic

Post by RBart »

Hi

I have a connection with my local MariaDB database. One of the columns returns "Belg?" instead of "België" in PureBasic.
The collation is "utf8_bin" already changed from "utf_general_ci".
I'm on Linux Ubuntu 22.04
In phpMyAdmin the value is "België".

result of the debugging, the value is already corrupted before using it in the application:

Belgi?
Type= 2 Naam= Land

Connection is made with:
UseMySQLDatabase()
If OpenDatabase(#Database, "host=localhost port=3306 dbname='NameDB'", "root", "",#PB_Database_MySQL)
piece of the code:

Code: Select all

 While NextDatabaseRow(#Database) ; as long as there are records
          Record$=""
          For i = 0 To DatabaseColumns(#Database) ;get columns 
             KolomType$ = Str(DatabaseColumnType(#Database, i)) 
             KolomNaam$ = DatabaseColumnName(#Database,i)
            RawValue$ = GetDatabaseString(#Database,i)
            If KolomType$= "2"  ; type = text          
                EscapedValue$ = ReplaceString(RawValue$, "ë", "ë") ; Voor voorbeeld, escape 'ë' ; this does not work because the value is already "?"                
                Debug EscapedValue$
            Else
                EscapedValue$ = RawValue$    
            EndIf
            Record$ =Record$ + Chr(10) + EscapedValue$;GetDatabaseString(#Database, i)   ;gegevens ophalen  
            
            Debug "Type= " + KolomType$ + " Naam= " + KolomNaam$            
           ; Break stops after first column
          Next         
          AddGadgetItem(#frmKlanten_lstKlanten,-1,Record$) ;lijn met gegevens toevoegen
          RecordCount.i = RecordCount.i + 1 
          Break ; stops after first record
        Wend
What am I doing wrong here?

Many thanks in advance,

Rudi
💻 Exploring the world of PureBasic
Fred
Administrator
Administrator
Posts: 18434
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: MariaDB /MySQL returns ? instead of ë In PureBasic

Post by Fred »

PB should work fine with utf8 column, did you change the column before or after the insert ?
User avatar
RBart
User
User
Posts: 33
Joined: Sun May 04, 2025 11:18 am

Re: MariaDB /MySQL returns ? instead of ë In PureBasic

Post by RBart »

It was utf8_general_c and it gave Belgi?.
PureBasic requires utf8
Couldn't select utf8 choise for utf8_bin instead. No solution.
💻 Exploring the world of PureBasic
User avatar
RBart
User
User
Posts: 33
Joined: Sun May 04, 2025 11:18 am

Re: MariaDB /MySQL returns ? instead of ë In PureBasic

Post by RBart »

It's via XAMPP 8.2.4-0
Config:
socket =/opt/lampp/var/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
default-character-set=utf8mb4
[mysqld]
user=mysql
port=3306
socket =/opt/lampp/var/mysql/mysql.sock
key_buffer=16M
max_allowed_packet=1M
table_open_cache=64
sort_buffer_size=512K
net_buffer_length=8K
read_buffer_size=256K
read_rnd_buffer_size=512K
myisam_sort_buffer_size=8M
💻 Exploring the world of PureBasic
User avatar
mk-soft
Always Here
Always Here
Posts: 6479
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: MariaDB /MySQL returns ? instead of ë In PureBasic

Post by mk-soft »

I think (as I have read) umlauts are not allowed in the columns.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
RBart
User
User
Posts: 33
Joined: Sun May 04, 2025 11:18 am

Re: MariaDB /MySQL returns ? instead of ë In PureBasic

Post by RBart »

mk-soft wrote: Sun Jan 11, 2026 4:22 pm I think (as I have read) umlauts are not allowed in the columns.
Which columns do you mean? MariaDB or PureBasic. Where did you read it? In phpMyAdmin the columns show the correct value.
💻 Exploring the world of PureBasic
User avatar
RBart
User
User
Posts: 33
Joined: Sun May 04, 2025 11:18 am

Re: MariaDB /MySQL returns ? instead of ë In PureBasic

Post by RBart »

Temporaly solved it with:

Code: Select all

EscapedValue$ = ReplaceString(RawValue$, "?", "ë")

But this will also change any other character that is not supported. So I could make it more specific like

Code: Select all

EscapedValue$ = ReplaceString(RawValue$, "Belgi?", "België")
So this not a real solution yet.
💻 Exploring the world of PureBasic
Post Reply