O
O
olafars2018-02-14 14:36:16
PHP
olafars, 2018-02-14 14:36:16

Text encoding problem?

Greetings! I got a product for development / support and immediately a problem surfaced, as it turned out, chronic. On the service, there is some import from the csv file, the data is written to the database. DB encoding utf8_unicode_ci. And in one of the fields of the database, such a symbol \ufeff comes across , values ​​​​are taken from the database and a string is formed to be sent via SOAP to the 1C server.
On the 1C side, it reads like ? - i.e. the character is not printable, I googled, found the answer:
www.fileformat.info/info/unicode/char/FEFF/index.htm
How can I now pick out this character from this line?
Will the regular expression be enough to leave only numbers and punctuation marks?
For example:
preg_replace("/[^,:;.0-9]/", '', $string);
The problem was discovered when I began to write the data sent by json to the log file, the line that causes problems looks like this:

\ufeff144732:2:112,20;151312:2:325,50;\ufeff144732:2:112,20;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2018-02-14
@BorisKorobkov

How can I now pick out this character from this line?

php.net/manual/en/function.str-replace.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question