Lazarus

Programming => Networking and Web Programming => Topic started by: mica on April 17, 2018, 10:59:04 pm

Title: [solved] indy IRC and Umlauts
Post by: mica on April 17, 2018, 10:59:04 pm
I tried  Indy and the IRC Component with the Twitch IRC.

If IdIRC1.Say(channel,message) contains an Umlaut (äöü) the message doesent
show in the Chat .

System is Openesuse Linux Lazarus 1.8
Title: Re: indy IRC and Umlauts
Post by: Remy Lebeau on April 20, 2018, 09:26:12 pm
If IdIRC1.Say(channel,message) contains an Umlaut (äöü) the message doesent
show in the Chat .

The IRC protocol does not provide any provisions for handling Unicode data.  Text is sent as arbitrary bytes, clients can use whatever charsets they want, and have to manually detect and decode whatever they receive.  It is not uncommon to see text transmitted in charsets like ISO-8859-1, KOI8-R, SHIFT-JIS, ISO-2022-JP, etc.  However, UTF-8 is very common nowadays.

TIdIRC does not have any direct support for handling text encodings, it relies on whatever the DefStringEncoding and AnsiEncoding properties of its IOHandler are set to, which are set to ASCII and OSDefault by default, respectively.  That is why you are losing non-ASCII characters, like Umlauts.

After connecting to the IRC server and before sending any IRC commands, such as in the OnConnected event, you can set the IOHandler's DefStringEncoding and DefAnsiEncoding properties to whatever you want, such as IndyTextEncoding_UTF8.
Title: Re: indy IRC and Umlauts
Post by: mica on April 21, 2018, 12:12:39 am
Thanks Remy Lebeau, i think this solved my issue

IdIRC1.IOHandler.DefStringEncoding:=IndyTextEncoding_UTF8;
IdIRC1.IOHandler.DefAnsiEncoding:=  IndyTextEncoding_UTF8;

in the connected Event
TinyPortal © 2005-2018