Recent

Author Topic: [solved] indy IRC and Umlauts  (Read 1024 times)

mica

  • Full Member
  • ***
  • Posts: 191
[solved] indy IRC and Umlauts
« 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
« Last Edit: April 21, 2018, 12:12:59 am by mica »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 517
    • Lebeau Software
Re: indy IRC and Umlauts
« Reply #1 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.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

mica

  • Full Member
  • ***
  • Posts: 191
Re: indy IRC and Umlauts
« Reply #2 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