[asterisk-users] SendText and non-ASCII characters

Philipp Kempgen philipp.kempgen at amooma.de
Mon Nov 24 13:08:23 CST 2008


Olivier schrieb:
> 2008/11/24 Philipp Kempgen <philipp.kempgen at amooma.de>
> 
>> Olivier schrieb:
>>
>> > At the moment, I'm trying to send "Unicoded" text
>>
>> Unicode is not an encoding. It's just a list or table of characters
>> (glyphs).
>> http://en.wikipedia.org/wiki/Unicode
>> Unicode is typically represented in encodings (misleadingly called
>> "charsets") such as UTF-8, UTF-16 ...
>> http://en.wikipedia.org/wiki/UTF-8
>> http://en.wikipedia.org/wiki/UTF-16
>>
>> > to a SIP phone using
>> > dialplan application SendText.
>> >
>> > SendText("Hello World") works.
>> > How can I insert letter 00E9 (from
>> > http://www.unicode.org/charts/PDF/U0080.pdf) which can be written
>> &eacute;
>> > in HTML ?
>>
>> Interesting. Maybe an Asterisk developer can comment on that.
>> I'd try to type the character (latin small letter e with acute) in
>> the text editor of your choice and either save the file in
>> ISO-8859-1 encoding or in UTF-8 encoding so when viewed in a
>> hexdump (hd) it has 2 bytes: C3 A9
>> http://www.utf8-chartable.de/unicode-utf8-table.pl?start=233
>>
>> But I thought you were trying to avoid "non-english" characters
>> because the phone doesn't display them anyway.
> 
> 
> Obviously, the phone (Thomson st2030s) displays several latin charsets but
> the media to use for that is to use SIP MESSAGE.
> Thanks to your (crystal clear) explaination, I suppose I can't tailor
> SendText to use UTF-8 encoding so I typed the decompositioned form (ie
> "e´").
> It doesn't display the way I wanted to.
> 
> If I could simply use non-ascii in dialplay functions ...

The required modification to add ";charset=UTF-8" to the Content-
Type header is simple and has already been done in Asterisk 1.6.1
(not in 1.6.0). It's in the add_text() function in chan_sip.c:
http://svn.digium.com/view/asterisk/tags/1.4.22/channels/chan_sip.c?view=markup#l_6229
http://svn.digium.com/view/asterisk/tags/1.6.0.1/channels/chan_sip.c?view=markup#l_7747
http://svn.digium.com/view/asterisk/tags/1.6.1-beta1/channels/chan_sip.c?view=markup#l_8022

  /*! \brief Add text body to SIP message */
  static int add_text(struct sip_request *req, const char *text)
  {
    /* XXX Convert \n's to \r\n's XXX */
-   add_header(req, "Content-Type", "text/plain");
+   add_header(req, "Content-Type", "text/plain;charset=UTF-8");
    add_header_contentLength(req, strlen(text));
    add_line(req, text);
    return 0;
  }

You could easily make the same modification in 1.4 or 1.6.0.
It may help or it may not. Depends on the phone.

> I also tried URIENCODE ...

Not the way to go here.

>> If that's what you want then just send one of the decompositioned
>> forms, namely "e´" or just "e" (easy to type).


   Philipp Kempgen

-- 
http://www.das-asterisk-buch.de  -  http://www.the-asterisk-book.com
Amooma GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
-- 



More information about the asterisk-users mailing list