���� � �����������, ����������� � ��������� ������ � ��������
����� ��������� ����� �� CP1251 �� UTF-8
��������� ��� ����� ������ � LAMP �� LNAMP, ��� ���������� ��������� NGINX. � ��� �� ������, ���� �� �� ����� ����������� ���������� � ��������� Windows-1251 (cp1251).
��� ��� ���������� ������ � ��� ������� �����, ���� ������� ������ ��������� � � ������ ����������� ��������� ����� cp1251 � �������� �������� ����� �� ������������. ��, ��� �� �����, � ������ �� ��� ��� ����������� ����� ����������, ������� ������� ����� � ��������� CP1251.
��� ������, ��� ���������� ����� � ISP Panel ��� ���� �� ��������, � ��� ��� ������� �������� ���� �� ���� � Vesta CP, ��������� ����� �� ������� � ������������. ������� ���� ������������� ������ Nginx, �������������� ��������� ���� �������� ���������. ��, ��������� � �����, � ���� ���� ����� � ������� �� ������� � � ��� ���, � ������ ������� ���� �� LAMP.
��� ��� ���������� ���� ������� � ������� ������ ������������� �������� ��������� � NGINX, ���� ������������ ����� � ������ ��� ������� UTF-8. ������� ��� ����� ���������� ���������� ��������� Notepad++ ����� �������� ��������� ��������� � ������������ ����������; ���� �� � ����� ������. ��� � ���� �������, ���� �����������, �� ���� �� ������, ��� ������������� ���� ������. ������� �������������� ���� ���� ������ �����. � ����� ������ ��� ����������� �� ��������� �����.
������������� ����� �� CP1251 � UTF-8 ������������ � ������� ����� ������� iconv
# iconv -f cp1251 -t utf8 FILE-CP1251 -o FILE-UTF8
���� �� ����� ���������� ���� � ������ ����
# iconv -f cp1251 -t utf8 file.txt -o file.txt
�� ��������� ��� ���� ���� �������������� ������� ����� ������ php, ������������ � ������ ������, �� ��� �������� ��������� ��������� �����������:
# find /path-to-files/ -type f -name *php -exec iconv -f cp1251 -t utf-8 ‘<>‘ -o ‘<>‘ ;
��������� ��� � ���.
��� ����������� ��������� ���� ��� ������� enconv, �������� � ������ ������ enca � ��� �� ��� ��� ��������� ��� � ���� �� ���������, ������������� ���� �������� ����������:
# enconv -c file.txt
��, � ���������, � ��� �� ���� ��������� � ������� ������, �.� ���� ��� �������� ����� ����� ������ -L russian ������ ��������� �� ������. �� � ������ �������, ��� ��������� �������� � ����� iconv
I have a problem converting a string from cp1251 to utf8.
I need to get some names from database and those names are in cp1251(i’m not the one who made that database, so I can’t edit it, but I know for sure that these names are cp1251).
The name in database is this — «�?нтернет в цифрах» I’m converting it to utf8 using iconv function like this:
and what I have in the result is this — «??������� � ������»(it’s Russian), but the first two symbols are not correct. it should be «�������� � ������».
So the final thing that I have to do is somehow change these two symbols «??» to russian letter «�». and I really don’t know how to do that. I’ve tried to use preg_replace, but it doesn’t work. or I’m not using it correctly.
And I’m sorry for Russian letters, it is really hard to explain what I need without showing them.
�� ���, � ��������� ��� � ���� �������� ������������� �������� �������� ������ ������, ������� ��� ���������� ������� ��� ������ � IAR-�.
����� ��������� ��� �� ����� ���������, ����� ������� �������������� ��������� �����. �������� ��������� � CP1251 �� UTF-8.
��� ����� ���� � Ubuntu ������� ������� iconv, ������� ����� ������� ��� ���������:
� ��� �� ������ ��� �������� �����.
� �������� ����� ������������ �� �������� ��������� ��, �� ���� ������ �� ������� ���� ��������. ����� ���������� �� ����� ��������� ��������� ������� ������. � ��� ��� ��� � ���� UTF-8.
����� ���� �� ��������� ������� ��������� ���. ������� ���� ���������� ���������� ��.
�� � ���-�� �� ����� ���� ������� �����, ������� �������� ���.
���� ��� �������� � ��� ��������� �����, �� ������� ������ ���������������� ����� �� �������:
������ ����� ������ �����. ��, ��������, ��� �������� ������������ ������. ����� �������� ����� � ������� less, ����� ���������� ����� ����� ������������ ����� � ����:
�� ���, ���������� � ���, ��� �������� ����� �������������.
�� ��� ������, ����� ������ �����? �������� ������� ��� ������������� ������� ����� ������� � �� Unix-way! ������� ������� ������, ������� ��������� ��� ����� � ������� ���������� � ������������.
�������� ��� � ����� � ������ win2lin � ������������� bin ��������� ����������. �� ��� ��� �� ��� ����������.