The problem is this: there is a .DBF file. I open it:

$dbh = dbase_open("bnk.dbf",2); if(!$dbh) exit("Ошибка - невозможно открыть файл"); $numrecords = dbase_numrecords($dbh); for($i = 0; $i < $numrecords; $i++) { $arr[] = dbase_get_record($dbh, $i); } echo "<pre>"; print_r($arr); echo "<pre>"; dbase_close($dbh); 

Everything outputs, but the words that are in the $arr array are not displayed correctly! With the encoding problem! Who knows, help!

    2 answers 2

    DBF file can be in ANSI and DOS encodings. In the program that works with the dbf file, you can set the encoding, and from this it is worth building a subsequent solution to the problem.

    If the encoding can be changed, then you need to change it to the one that uses the script, for example, cp1251 or utf-8.

    If it is not possible to change it in the program, then you need to find out in what encoding the file and under it adjust the decoding to the desired encoding.

    And in a completely clinical case, the script must determine the encoding itself and perform decoding.

    What is your case of the three described?

    • one
      This file was in ASCII encoding! I thought he was in DOS, suffered a lot, and then climbed on the net and remembered such a function: convert_cyr_string ($ arr [$ i] [$ j], 'd', 'w'); and it worked! - chambo

    There is also the iconv function, but it only works with strings, not arrays.