1
1
1010101010102014-10-14 23:50:12
PHP
101010101010, 2014-10-14 23:50:12

How to replace broken characters in utf-8 encoding php?

Hello, I get the page of the site using curl and write it to a string. And here's the bad luck, the symbol "x" turns out to be broken for some unclear reason, instead of it a rhombus with a question mark. I need to somehow replace it back with "x" , but I don't know how to get the code of this broken character. Maybe someone knows how to solve this problem, I've been fighting for more than a day.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alektive, 2014-10-15
@alektive

Doesn't it help? https://php.net/manual/ru/function.str-replace.php
Or https://php.net/manual/ru/function.preg-replace.php

A
Andrew, 2014-10-15
@ntzch

I can assume that the encoding was recognized incorrectly, as I was parsing one site the other day, there was a complete mess with the encoding, I wrote a small function that checks in which encoding the string is displayed better, takes one parameter - a string, returns an array, where the keys are the name of the encoding , and the values ​​are a string encoded with that encoding. Hope that helps pastebin.com/7TtCbP3x

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question