Reading (and keeping) Accented and Special Characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernhard Georg Enders

    Reading (and keeping) Accented and Special Characters

    I'm using the php 'file' command to read the contents of an ASCII text
    file to a variable. The original text file contains some accented and
    special characters. The problem arises when I echo this variable: the
    accented characters are messed up. And not only accented characters, for
    example, the special characters ª is printed as ª. What can I do to
    correct this issue? I have tried, without success, to use the 'setlocale'
    command.

    TIA,

    Bernhard Enders.
  • Pedro Graca

    #2
    Re: Reading (and keeping) Accented and Special Characters

    Bernhard Georg Enders wrote:[color=blue]
    > I'm using the php 'file' command to read the contents of an ASCII text
    > file to a variable. The original text file contains some accented and
    > special characters.[/color]

    Those are not ASCII characters!
    [color=blue]
    > The problem arises when I echo this variable: the
    > accented characters are messed up. And not only accented characters, for
    > example, the special characters ª is printed as ª. What can I do to
    > correct this issue?[/color]

    Output the contents of the (not ASCII) text file using the same
    character encoding that was used to create the file.
    [color=blue]
    > I have tried, without success, to use the 'setlocale'
    > command.[/color]

    You may be able to read whatever encoding was used for the file and
    convert it:





    Happy Coding :-)
    --
    USENET would be a better place if everybody read: | to mail me: simply |
    http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
    http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
    http://www.expita.com/nomime.html | and *NO* attachments. |

    Comment

    Working...