Page 1 of 1

MariaDB /MySQL returns ? instead of ë In PureBasic

Posted: Sat Jan 10, 2026 1:23 pm
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

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

Posted: Sat Jan 10, 2026 4:28 pm
by Fred
PB should work fine with utf8 column, did you change the column before or after the insert ?

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

Posted: Sun Jan 11, 2026 11:56 am
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.

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

Posted: Sun Jan 11, 2026 4:11 pm
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

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

Posted: Sun Jan 11, 2026 4:22 pm
by mk-soft
I think (as I have read) umlauts are not allowed in the columns.

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

Posted: Mon Jan 12, 2026 11:24 am
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.

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

Posted: Mon Jan 12, 2026 11:59 am
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.