PHP Developers Network
http://forums.devnetwork.net/

ANSI to UTF-8 - how to preserve special characters?
http://forums.devnetwork.net/viewtopic.php?f=14&t=139444
Page 1 of 1

Author:  anivad [ Sat Mar 22, 2014 11:02 pm ]
Post subject:  ANSI to UTF-8 - how to preserve special characters?

I've got about 3000 text files encoded in ANSI (windows-1252) that I'd like to convert to UTF-8. I used UTFCast to do that, but now all my special characters are turning up wonky - smart quotes, emdashes, accented letters, and so on are either appearing as question marks or weird characters.

Is there any way for me to preserve those special characters while doing the conversion? There are way too many files for me to do this with a manual search and replace, especially since I won't know if I've fixed every instance of this unless I go through each file to check. Even if I stick to just the foreign-language files, there are probably at least a hundred.

Any help would be greatly appreciated, thanks!

Author:  Christopher [ Sat Mar 22, 2014 11:22 pm ]
Post subject:  Re: ANSI to UTF-8 - how to preserve special characters?

From the Unix command line or any language with access to the standard C library you cat try iconv.

Command line: http://www.gnu.org/savannah-checkouts/g ... onv.1.html
PHP docs: http://www.php.net/manual/en/book.iconv.php

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/