comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: Re: string and wide string usage
Date: Thu, 7 Mar 2013 06:20:05 -0800 (PST)
Date: 2013-03-07T06:20:05-08:00	[thread overview]
Message-ID: <5e5e7e80-7d69-47e1-9550-19e2e0a211a9@googlegroups.com> (raw)
In-Reply-To: <kh9sm1$tj4$1@dont-email.me>

On Thursday, March 7, 2013 8:12:01 PM UTC+9, Ali Bendriss wrote:
> I've got some problem with some string in example:
> a base 64 encoded string
> V2luZG93c8KgNyBQcm9mZXNzaW9ubmVsIE4=
> wich decode to 'Windows\xa07 Professionnel N' in utf-8
> every thing is working if I feed directly the database, but if want to 
> apply Ada.Characters.Handling.To_Lower on the string before feeding the 
> database postgres is not happy 
> 'ERROR:  invalid byte sequence for encoding "UTF8": 0xe2 0xa0 0x37'
> it's not really a big deal, but I would like to understand where the 
> problem is. Do I have to use wide string ?

Because functions in Ada.Characters.Handling take not UTF-8 but Latin-1.
You have to
1. convert UTF-8 String to Wide_Wide_String, process UTF-32 and restore it to UTF-8.
  (Ada.Characters.Conversion also take Latin-1. You have to use GNAT.Encode_String/Decode_String or Ada.Strings.UTF_Encoding for converting.)
2. search a external library to process UTF-8 directly.



  reply	other threads:[~2013-03-07 14:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07 11:12 string and wide string usage Ali Bendriss
2013-03-07 14:20 ` ytomino [this message]
2013-03-07 17:14   ` Dmitry A. Kazakov
2013-03-07 23:53   ` Randy Brukardt
2013-03-08  2:05     ` Yannick Duchêne (Hibou57)
2013-03-08  3:07       ` Randy Brukardt
2013-03-07 17:48 ` Vadim Godunko
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox