PHP : Unknown encoding in CSV file -


i'm kinda new encoding issues

i have csv file client , can't figure out how encoded

i have "é" accents appears � in vim or openoffice, when try encode them utf8 using mb_convert_encoding( $string, "utf-8" ) or utf8_encode($string) "�"

i tried latin encodings (iso-8859-1, iso-8859-15) utf8 iconv , mb_convert_encoding

i tried method found convert cp1250 utf8 , 1 macintosh utf8

still no luck. there way find solution without asking client change csv encoding utf8 ?

thanks lot !

edit in order find correct encoding parsed encodings listed in mb_list_encodings() , tried convert utf-8 each of them. none of them render "é". i'll ask client use utf-8 when exports csv

using vim hexadecimal value of wrong character can � character in file , encoding issue client-side

you need know encoding file in, period. if don't know that, try view document bunch of different encodings (e.g. in text editors have option of file → reopen using encoding... or similar such actions), until find encoding file makes sense in.

that, or convert file different encodings preferred encoding. mb_convert_encoding($string, "utf-8") won't help, can't magically guess convert from. try:

echo mb_convert_encoding($string, 'utf-8', 'iso-8859-1'); echo mb_convert_encoding($string, 'utf-8', 'sjis'); ... 

until you've found encoding document looks correct.

if guessing doesn't help, ask originator of document pay attention encoding they're using, or tell them explicitly provide document in encoding need.

read what every programmer absolutely, positively needs know encodings , character sets work text.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -