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
13
votes
7 answers

Converting a \u escaped Unicode string to ASCII

After reading all about iconv and Encoding, I am still confused. I am scraping the source of a web page I have a string that looks like this: 'pretty\u003D\u003Ebig' (displayed in the R console as 'pretty\\\u003D\\\u003Ebig'). I want to convert this…
seancarmody
  • 6,182
  • 2
  • 34
  • 31
13
votes
1 answer

Using iconv to convert from UTF-16BE to UTF-8 without BOM

I'm trying to convert a UTF-16BE encoded file (byte order mark: 0xFE 0xFF) to UTF-8 using iconv like so: iconv -f UTF-16BE -t UTF-8 myfile.txt The resulting output, however, has the UTF-8 byte order mark (0xEF 0xBB 0xBF) and that is not what I…
Edward Samson
  • 2,395
  • 2
  • 26
  • 39
12
votes
2 answers

What factors influence a successful iconv() TRANSLIT conversion?

I am trying to determine what environmental or other factors have an influence on the result of a call to iconv() with the TRANSLIT option. The following code has different results for me locally when run through Apache and CLI.
drewm
  • 2,003
  • 1
  • 16
  • 22
12
votes
6 answers

Equivalent of Iconv.conv("UTF-8//IGNORE",...) in Ruby 1.9.X?

I'm reading data from a remote source, and occassionally get some characters in another encoding. They're not important. I'd like to get get a "best guess" utf-8 string, and ignore the invalid data. Main goal is to get a string I can use, and not…
Jordan Warbelow-Feldstein
  • 10,510
  • 12
  • 48
  • 79
12
votes
4 answers

iconv_strlen function causing execution timeout, running on MAMP

Has anyone had issues with the iconv_strlen function while running MAMP?
blacktie24
  • 4,985
  • 6
  • 41
  • 52
12
votes
3 answers

Ruby converting string encoding from ISO-8859-1 to UTF-8 not working

I am trying to convert a string from ISO-8859-1 encoding to UTF-8 but I can't seem to get it work. Here is an example of what I have done in irb. irb(main):050:0> string = 'Norrlandsvägen' => "Norrlandsvägen" irb(main):051:0>…
charint
  • 155
  • 1
  • 1
  • 10
12
votes
3 answers

Convert Javascript UTF-8 to ASCII (like Iconv('UTF-8', 'ASCII//TRANSLIT', $string) in PHP)

I'm wondering how it's possible to 'translate' characters in UTF-8 to the closest ASCII equivalent using Javascript, just like Iconv doest in PHP. Example: ü becomes uó becomes o I'd rather not use a replace, because a) it requires a complete set of…
Simon
  • 5,464
  • 6
  • 49
  • 85
11
votes
2 answers

Why can iconv convert precomposed form but not decomposed form of "É" (from UTF-8 to CP1252)

I use the iconv library to interface from a modern input source that uses UTF-8 to a legacy system that uses Latin1, aka CP1252 (superset of ISO-8859-1). The interface recently failed to convert the French string "Éducation", where the "É" was…
Jean-Denis Muys
  • 6,772
  • 7
  • 45
  • 71
11
votes
1 answer

iconv or mbstring?

Which multibyte-handling library should I use : iconv or mbstring ? After some Googling I didn't find enough arguments to convince me to use one particularly, and I could not get any benchmark (and I'm too lazy do create one :-p). After all maybe…
Maxime Pacary
  • 22,336
  • 11
  • 85
  • 113
11
votes
1 answer

iconv "incomplete character or shift sequence at end of buffer" error

I imports data from another server. Then my script converts it to .txt. .csv file which i imported: dddd-cccc bbbbbb aaaa xx List_2015_10_27.csv iconv command: iconv -f UCS-2 -t UTF-8 /thepath/*List_2015_10_27.csv > /thepath/newfile.txt It was…
omega
  • 123
  • 1
  • 7
10
votes
5 answers

How can I force PHP to use the libiconv version of iconv instead of the CentOS-installed glibc version?

The code I'm working on runs perfectly on Windows XP and on Mac OS X. When testing it on CentOS (and on Fedora and Ubuntu), it's not working properly. Searching the nets led me to the conclusion that it's the glibc version of the iconv that's…
Randell
  • 6,112
  • 6
  • 45
  • 70
10
votes
5 answers

Debug iconv_strlen error - PHP 5.5

I am trying to export a document to PDF using Laravel & DomPDF. This works on my mac, but not on staging or live server. Error as follows: I have no idea what this means, and cannot find any solutions. iconv_strlen(): Wrong charset, conversion…
Gravy
  • 12,264
  • 26
  • 124
  • 193
9
votes
2 answers

Convert files between UTF-8 and ISO-8859 on Linux

Every time that I get confronted with Unicode, nothing works. I'm on Linux, and I got these files from Windows: $file * file1: UTF-8 Unicode text file2: ISO-8859 text file3: ISO-8859 text Nothing was working until I found out that the files have…
user3182532
  • 1,097
  • 5
  • 22
  • 37
9
votes
3 answers

PHP compile fails with undefined symbols for architecture x86_64, libiconv on macOS Sierra

I have upgraded a Mac to macOS 10.12.0 Sierra, and am trying to upgrade PHP to version 7.0.9, but 'make test' fails with: Undefined symbols for architecture x86_64: "_libiconv", referenced from: _zif_iconv_substr in iconv.o …
jlbrown
  • 121
  • 1
  • 6
9
votes
1 answer

PHP, convert UTF-8 to ASCII 8-bit

I'm trying to convert a string from UTF-8 to ASCII 8-bit by using the iconv function. The string is meant to be imported into an accounting software (some basic instructions parsed accordingly to SIE standards). What I'm running now: iconv("UTF-8",…
Daniel
  • 3,726
  • 4
  • 26
  • 49
1 2
3
42 43