Questions tagged [iconv]

iconv is a library and API for converting between different character encodings.

iconv can refer to one of three things:

  1. The iconv() API call standardised as part of the POSIX specification.
  2. The iconv command-line utility, also part of the POSIX specification.
  3. The libiconv library, a GNU project that implements the iconv() API and command-line utility.

In all cases, the API/utility/library is used to convert text between different formats.

631 questions
115
votes
31 answers

How do I remove accents from characters in a PHP string?

I'm attempting to remove accents from characters in PHP string as the first step to making the string usable in a URL. I'm using the following code: $input = "Fóø Bår"; setlocale(LC_ALL, "en_US.utf8"); $output = iconv("utf-8", "ascii//TRANSLIT",…
georgebrock
  • 28,393
  • 13
  • 77
  • 72
74
votes
12 answers

Force encode from US-ASCII to UTF-8 (iconv)

I'm trying to transcode a bunch of files from US-ASCII to UTF-8. For that, I'm using iconv: iconv -f US-ASCII -t UTF-8 file.php > file-utf8.php My original files are US-ASCII encoded, which makes the conversion not happen. Apparently it occurs…
eightyfive
  • 4,601
  • 3
  • 35
  • 44
56
votes
10 answers

How can I write a file in UTF-8 format?

I have bunch of files that are not in UTF-8 encoding and I'm converting a site to UTF-8 encoding. I'm using simple script for files that I want to save in UTF-8, but the files are saved in old encoding: header('Content-type: text/html;…
Starmaster
  • 842
  • 1
  • 6
  • 9
46
votes
7 answers

iconv - Detected an illegal character in input string

I don't see anything illegal - any suggestions on what might be the problem? if (strtolower($matches[1]) != 'utf-8') { var_dump($matches[1]); $xml = iconv($matches[1], 'utf-8', $xml); $xml =…
Ben
  • 60,438
  • 111
  • 314
  • 488
42
votes
12 answers

Batch convert latin-1 files to utf-8 using iconv

I'm having this one PHP project on my OSX which is in latin1 -encoding. Now I need to convert files to UTF8. I'm not much a shell coder and I tried something I found from internet: mkdir new for a in `ls -R *`; do iconv -f iso-8859-1 -t utf-8…
Jasmo
  • 808
  • 2
  • 9
  • 17
38
votes
4 answers

iconv: Converting from Windows ANSI to UTF-8 with BOM

I want to use iconv to convert files on my Mac. The goal is to go from "Windows ANSI" to "whatever Windows Notepad saves, if you tell it to use UFT8". This is what I want: $ file names.csv names.csv: UTF-8 Unicode (with BOM) text, with CRLF line…
user531912
  • 383
  • 1
  • 3
  • 5
36
votes
14 answers

R tm package invalid input in 'utf8towcs'

I'm trying to use the tm package in R to perform some text analysis. I tied the following: require(tm) dataSet <- Corpus(DirSource('tmp/')) dataSet <- tm_map(dataSet, tolower) Error in FUN(X[[6L]], ...) : invalid input 'RT @noXforU Erneut riesiger…
maiaini
  • 692
  • 1
  • 9
  • 13
32
votes
5 answers

How can I detect a malformed UTF-8 string in PHP?

The iconv function sometimes gives me an error: Notice: iconv() [function.iconv]: Detected an incomplete multibyte character in input string in [...] Is there a way to detect that there are illegal characters in a UTF-8 string before sending data…
rsk82
  • 28,217
  • 50
  • 150
  • 240
32
votes
2 answers

PHP: Dealing special characters with iconv

I still don't understand how iconv works. For instance, $string = "Löic & René"; $output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $string); I get, Notice: iconv() [function.iconv]: Detected an illegal character in input string in... $string…
Run
  • 54,938
  • 169
  • 450
  • 748
30
votes
6 answers

_libiconv or _iconv undefined symbol on Mac OSX

When compiling some packages from source on Mac OSX, I get the following iconv error: Undefined symbols for architecture x86_64: "_iconv", referenced from: "_iconv_close", referenced from: "_iconv_open", referenced from: or I get: Undefined…
John Q
  • 1,262
  • 2
  • 13
  • 19
29
votes
3 answers

Why iconv cannot convert from utf-8 to iso-8859-1

My system is SUSE Linux Enterprise Server 11. I'm trying to convert a data from utf-8 format to iso useing "iconv" $>file test.utf8 test.utf8: UTF-8 Unicode text, with very long lines $> $>file -i test.utf8 test.utf8: text/plain…
Łukasz Bensz
  • 391
  • 1
  • 3
  • 5
26
votes
3 answers

libiconv not linking to iOS project

I'm trying to compile MailCore into an iOS app I'm making, and the linker keeps complaining that libiconv isn't linked in. At least that's what I think it's complaining about. This is what it spits out: Undefined symbols for architecture i386: …
sarahhodne
  • 9,796
  • 3
  • 39
  • 44
24
votes
8 answers

iconv any encoding to UTF-8

I am trying to point iconv to a directory and all files will be converted UTF-8 regardless of the current encoding I am using this script but you have to specify what encoding you are going FROM. How can I make it autdetect the current…
Blainer
  • 2,552
  • 10
  • 32
  • 39
24
votes
6 answers

Transliterate any convertible utf8 char into ascii equivalent

Is there any good solution out there that does this transliteration in a good manner? I've tried using iconv(), but is very annoying and it does not behave as one might expect. Using //TRANSLIT will try to replace what it can, leaving everything…
Ivan Hušnjak
  • 3,493
  • 3
  • 20
  • 30
21
votes
3 answers

how to get list of supported encodings by iconv library in php?

Is it possible like in the mcrypt library with function mcrypt_list_algorithms(). Is there a iconv_list_encodings like function ?
rsk82
  • 28,217
  • 50
  • 150
  • 240
1
2 3
42 43