RE: [PHP] strange character
| From: | hadi | Date: | Wed, 25 Feb 2015 12:35:36 +0000 |
| Subject: | RE: [PHP] strange character | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324521@lists.php.net to get a copy of this message | ||
Im using linux centos. I have access to terminal.
I did what you asked converting the test.txt to CP1256
And to verify that I did,
file -bi test.txt
text/plain; charset=us-ascii
not showing cp1256 encoding. But when I do,
iconv -l | grep CP1256
CP1256//
I get CP1256 encoding.
> -----Original Message-----
> From: Peter West [mailto:lists@pbw.id.au]
> Sent: Wednesday, February 25, 2015 3:11 PM
> To: hadi; PHP General
> Subject: Re: [PHP] strange character
>
> > On 25 Feb 2015, at 9:06 pm, hadi <almarzuki2011@hotmail.com> wrote:
> >
> > Hi Peter,
> >
> > I want to convert from utf-8 to CP1256 so the strange character can be
> fixed.
>
> I think it's either a) already in CP1256, or it's in some other character set
> altogether. The error message is telling you that it's not recognised as UTF-8.
>
> Do you have access to the iconv program in a terminal? If you are on a linux
> or OS X system, just open a terminal and type
>
> iconv --help
>
> If you have iconv installed you will get a help message.
>
> Get the text you are trying to convert into a text file, and just try various
> conversions using iconv, until it looks right. Let's say your text is in the file
> unknown.txt.
>
> iconv -l
>
> will list all of the character sets that iconv knows about. Find the likely
> candidates and just try
>
> iconv -t UTF8 -f CP1252 unknown.txt
> iconv -t UTF8 -f CP1256 unknown.txt
> iconv -t UTF8 -f CP1254 unknown.txt
>
> etc, until it looks right.
>
> Peter West
> "...and behold, something greater than Jonah is here."
>
> >
> >> -----Original Message-----
> >> From: Peter West [mailto:lists@pbw.id.au]
> >> Sent: Wednesday, February 25, 2015 1:46 PM
> >> To: hadi
> >> Subject: Re: [PHP] strange character
> >>
> >> Aren't you going the wrong way? It looks as though the text you are
> >> trying to convert is one of the 8-bit character sets. From these
> >> sets you get bad characters because a character with the MSBit set
> >> will be interpreted by a
> >> UTF-8 system as a multi-byte character.
> >>
> >> Which way do you want to go: from CP1256 to UTF-8 or vice versa?
> >>
> >> Peter West
> >> "...and behold, something greater than Jonah is here."
> >>
> >>> On 25 Feb 2015, at 7:15 pm, hadi <almarzuki2011@hotmail.com> wrote:
> >>>
> >>> Hi,
> >>>
> >>>
> >>> Im trying to use (iconv("UTF-8", 'CP1256//TRANSLIT', $rss);)
> >>> to
> >>> convert strange character like (–) to proper character, but im
> >>> getting error
> >>>
> >>> I googled about it but never found anything about it.
> >>>
> >>> Here is the error
> >>>
> >>> Notice: iconv(): Detected an illegal character in input string in
> >>> /var/www/html/rssfeed/sahafah.php on line 35
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> >>> http://www.php.net/unsub.php
> >>>
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php