iconv to strip out specfic language characters

hello group,

I cannot figure out how to use iconv to "normalize" characters
specific to some language. I need it in file upload where I take a
file from local disc and then save to server and use in web pages, for
example, as img source.

What should be the second parameter of the function?

Say,
iconv('ISO-8859-1', 'ASCII//TRANSLIT', $str);
works but it gives too much transformed result.

I would like just replace specific chars, like "a acute", "a with
macron", "a umlaut", with a character without accent.


Andra.
kkadrese [ Di, 24 April 2007 14:28 ] [ ID #1696408 ]

Re: iconv to strip out specfic language characters

kkadrese [at] yahoo.com wrote:
> hello group,
>
> I cannot figure out how to use iconv to "normalize" characters
> specific to some language. I need it in file upload where I take a
> file from local disc and then save to server and use in web pages, for
> example, as img source.
>
> What should be the second parameter of the function?
>
> Say,
> iconv('ISO-8859-1', 'ASCII//TRANSLIT', $str);
> works but it gives too much transformed result.
>
> I would like just replace specific chars, like "a acute", "a with
> macron", "a umlaut", with a character without accent.

If there aren't a character that is the same in the two character setups, you
loose the characters, aring isn't the same as a, even if they may look like
the same and it's why it won't be represented in an ASCII character setup.

If you want to replace a character with a completely different one, then you
need to use ereg_replace or similar functions.

It's always a bad idea to convert a string to a less representative character
setup and ASCII is the bottom.

--

//Aho
Shion [ Di, 24 April 2007 18:23 ] [ ID #1696409 ]

Re: iconv to strip out specfic language characters

thank you,
I will stay now with
$str = iconv('ISO-8859-1', 'ASCII//IGNORE', $str);

Disappointingly that there is not such a function that would convert
language-specific characters to their ascii look-alikes. For me it
does not matter so much that it is not the same and more correct
representation would be specific for each language and so on so on...
I just need filenames to be used without problems and recognizable to
the author.

> > hello group,
> >
> > I cannot figure out how to use iconv to "normalize" characters
> > specific to some language. I need it in file upload where I take a
> > file from local disc and then save to server and use in web pages, for
> > example, as img source.
> >
> > What should be the second parameter of the function?
> >
> > Say,
> > iconv('ISO-8859-1', 'ASCII//TRANSLIT', $str);
> > works but it gives too much transformed result.
> >
> > I would like just replace specific chars, like "a acute", "a with
> > macron", "a umlaut", with a character without accent.
>
> If there aren't a character that is the same in the two character setups, you
> loose the characters, aring isn't the same as a, even if they may look like
> the same and it's why it won't be represented in an ASCII character setup.
>
> If you want to replace a character with a completely different one, then you
> need to use ereg_replace or similar functions.
>
> It's always a bad idea to convert a string to a less representative character
> setup and ASCII is the bottom.
>
> --
>
> //Aho
kkadrese [ Mo, 07 Mai 2007 12:13 ] [ ID #1706399 ]
PHP » alt.php » iconv to strip out specfic language characters

Vorheriges Thema: vSignup problem
Nächstes Thema: exec() Silent Death