Mam w komputerze zainstalowaną MariaDB która przy pomocy Engine Connect łączy się z staroświeckimi bazami DBF
Owe bazy posiadają mieszane kodowanie polskich znaków CP850+MAZOVIA które kiedyś wymyślił programista CLIPPER'a
(zapis polskich znaków lewym lub prawym "alt'em" = mix obu powyższych)

Rozwiązanie problemu konwersji kodowania do internetowego standardu UTF-8 póki co przeniosłem na serwer php,
ale tu pojawiły się schody. Zgodnie z moimi próbami, aby serwer php dostał w rezultacie zapytania mysqli_fetch_assoc($query)
binarny string danych możliwy do dalszych binarnych przekształceń w php, np. $str = str_replace("\x88", "\x92", $str), to:

a) tabele MySQL'a muszą mieć CHARSET=BINARY. Jeśli mam ustawiony jakikolwiek inny, zamiast polskich znaków mysqli_fetch_assoc() dostaje "?"

b) w/w kodowaniu generalnie mógłbym pracować, ale mam jedyny problem z porównywaniem w tym trybie pustych wartości CHAR(3) między atrybutami dwóch tabel, gdzie
'' = '' daje mi zawsze wynik "false".

Prosiłbym aby ktoś podrzucił rozwiązanie problemu B (załatwia sprawę), lub zaproponował lepsze rozwiązanie.

Póki co PHP dokonuje takich operacji, w wyniku którego JSON ma już właściwe kodowanie UTF-8:


$result = mysqli_query($conn, $query);
$data = array();

while($row = mysqli_fetch_assoc($result)){
	
    array_push($data, array_values($row));

}

foreach ($data as &$str) {
	
	
$str = str_replace("\xA9", "\x91", $str);
$str = str_replace("\xA8", "\x90", $str);
$str = str_replace("\x88", "\x92", $str);
$str = str_replace("\x9D", "\x9C", $str);
$str = str_replace("\xE4", "\xA4", $str);
$str = str_replace("\xE3", "\xA5", $str);
$str = str_replace("\xE0", "\xA3", $str);
$str = str_replace("\x97", "\x98", $str);
$str = str_replace("\xAB", "\xA6", $str);
$str = str_replace("\xBE", "\xA7", $str);
$str = str_replace("\xBD", "\xA1", $str);

//#####  MAZOVIA DO ISO8859-2  #####
/*
$str = str_replace("\xA1", "\xAF", $str);
$str = str_replace("\xA3", "\xD3", $str);
$str = str_replace("\xA6", "\xBC", $str);
$str = str_replace("\x86", "\xB1", $str);
$str = str_replace("\x8F", "\xA1", $str);
$str = str_replace("\x8D", "\xE6", $str);
$str = str_replace("\x95", "\xC6", $str);
$str = str_replace("\x91", "\xEA", $str);
$str = str_replace("\x90", "\xCA", $str);
$str = str_replace("\x92", "\xB3", $str);
$str = str_replace("\x9C", "\xA3", $str);
$str = str_replace("\xA4", "\xF1", $str);
$str = str_replace("\xA5", "\xD1", $str);
$str = str_replace("\xA2", "\xF3", $str);
$str = str_replace("\x9E", "\xB6", $str);
$str = str_replace("\x98", "\xA6", $str);
$str = str_replace("\xA0", "\xAC", $str);
$str = str_replace("\xA7", "\xBF", $str);
*/

//#####  MAZOVIA DO UTF8  #####

$str = str_replace("\xA1", "\xC5\xBB", $str);
$str = str_replace("\xA3", "\xC3\x93", $str);
$str = str_replace("\xA6", "\xC5\xBA", $str);
$str = str_replace("\x86", "\xC4\x85", $str);
$str = str_replace("\x8F", "\xC4\x84", $str);
$str = str_replace("\x8D", "\xC4\x87", $str);
$str = str_replace("\x95", "\xC4\x86", $str);
$str = str_replace("\x91", "\xC4\x99", $str);
$str = str_replace("\x98", "\xC5\x9A", $str);
$str = str_replace("\x90", "\xC4\x98", $str);
$str = str_replace("\x92", "\xC5\x82", $str);
$str = str_replace("\x9C", "\xC5\x81", $str);
$str = str_replace("\xA4", "\xC5\x84", $str);
$str = str_replace("\xA5", "\xC5\x83", $str);
$str = str_replace("\xA2", "\xC3\xB3", $str);
$str = str_replace("\x9E", "\xC5\x9B", $str);
$str = str_replace("\xA0", "\xC5\xB9", $str);
$str = str_replace("\xA7", "\xC5\xBC", $str);

//#####  ZNAKI NULL  #####
$str = str_replace("\x00", "", $str);

}

echo json_encode($data);