9

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", "ASCII", $this->_output)

This works for accounting software #1, but software #2 complains about the encoding. Specified encoding by the standard is: IBM PC 8-bit extended ASCII (Codepage 437).

My question is, what version of ASCII is PHP encoding my string into, and if other than specified - how can I encode the string accordingly to the standard specification?

Daniel
  • 3,726
  • 4
  • 26
  • 49
  • What kind of characters are in the string? If only characters of the first 128 code points, then UTF-8 is already identical to ASCII. Is there are other characters in there, then you're discarding a lot of information/characters. – deceze Aug 07 '12 at 09:58
  • It's a matter of compatibility. The importing software will follow the SIE standard and therefor only accept ASCII extended. – Daniel Aug 07 '12 at 11:31

1 Answers1

14

try this for the software #2

iconv("UTF-8", "CP437", $this->_output);

Extended ASCII is not the same as plain ASCII. The first one maybe accepts ASCII, but the second software requires Extended ASCII - Codepage 437

see this link

Vlad Balmos
  • 3,372
  • 19
  • 34