Z
Z
ZaurK2017-02-02 11:41:55
PHP
ZaurK, 2017-02-02 11:41:55

How to convert html file to utf-8 in php?

Good afternoon! I have an ANSI encoded html file (as shown by notepad), I need to resave this file by converting it to UTF-8. Is there a way to do this programmatically in php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@smple, 2017-02-02
@ZaurK

using php.net/manual/ru/function.mb-convert-encoding.php
for example:

$value = file_get_contents('path');
$result = mb_convert_encoding($value, 'целевая кодировка в твоем случае utf8 найди название под каким она на сервере', 'из какрой кодировки, опять же имя лучше взять как в ОС она называется');
file_put_content('путь для результата', $result);

this thing uses mb string it must be installed separately php.net/manual/ru/book.mbstring.php usually in debian based apt install php-mbstring

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question