Mailing List Archive

string encoding in my own markup
Hello Mediawiki users and hackers,

I use
$wgParser->setHook
to add my own markup and callback function. The string that I get in
this function seems to be utf8. Is there any way to get the string
encoded in latin-1? (Wherever this is possible) Or is this more a php
question or ...?

Patrick
Re: string encoding in my own markup [ In reply to ]
On Sep 15, 2004, at 2:11 AM, Patrick Gundlach wrote:
> I use
> $wgParser->setHook
> to add my own markup and callback function. The string that I get in
> this function seems to be utf8. Is there any way to get the string
> encoded in latin-1? (Wherever this is possible) Or is this more a php
> question or ...?

You can use $wgLang->iconv(), which is a wrapper around iconv (if
available) or utf8_decode/utf8_encode as a hacky fallback if iconv is
not available. $wgInputEncoding store the encoding internally used.

Since UTF-8 to Latin-1 conversion is lossy, you should only do this if
it's really necessary and you are unable to process Unicode text.

-- brion vibber (brion @ pobox.com)
Re: string encoding in my own markup [ In reply to ]
Hello Brion,

> On Sep 15, 2004, at 2:11 AM, Patrick Gundlach wrote:
>> I use
>> $wgParser->setHook
>> to add my own markup and callback function. The string that I get in
>> this function seems to be utf8. Is there any way to get the string
>> encoded in latin-1? (Wherever this is possible) Or is this more a php
>> question or ...?

Brion Vibber <brion@ikso.net> writes:
> You can use $wgLang->iconv(), which is a wrapper around iconv (if
> available) or utf8_decode/utf8_encode as a hacky fallback if iconv is
> not available. $wgInputEncoding store the encoding internally used.

iconv did the trick, thank you.
>
> Since UTF-8 to Latin-1 conversion is lossy, you should only do this if
> it's really necessary and you are unable to process Unicode text.

Yes sure. I'll keep an eye on it.



Thanks for your help,

Patrick