From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: wide_string and assertions
Date: Sat, 05 Jun 2004 09:10:55 +0200
Date: 2004-06-05T09:10:55+02:00 [thread overview]
Message-ID: <1224046.crrTJmpIeA@linux1.krischik.com> (raw)
In-Reply-To: c9qckk$agj$1@a1-hrz.uni-duisburg.de
Georg Bauhaus wrote:
> Randy Brukardt <randy@rrsoftware.com> wrote:
> : "Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> wrote in message
>
> :> In an assert(x, y), y has to be static. So I guess for y I
> :> will have to play tricks and use UTF-8 coding of static
> :> String values?
> :
> : Yes.
>
> OK. (Though I find it a bit inconsistent from some
> point of view not to be able to express failure descriptions
> in a language that is understood by local operators.)
>
> : As far as demand goes, you're the first person to mention it to my
> : knowledge -- which is suggests that the demand is low. :-)
>
> How do that do these things in China? Does anyone have some
> experience?
>
> : raise Assert_Error with To_UTF_8 ("Wide_Wide_String");
> : so that might be preferable for this purpose.
>
> Yes. This is what I'm currently doing with Wide_String and
> Raise_Exception.
>
>
> : (But you'll probably have to
> : write the function yourself; there doesn't seem to be much support for
> : including such functions in the Standard.)
>
> (It would be great if someone who know about surrogate characters could
> check the following. Martin, is this similar to your function?)
As I said the functions are based on the Unicode part of XML/Ada. Not point
reinventing the Wheel.
XML/Ada is based on:
type Unicode_Char is mod 2**32;
subtype Utf8_String is String;
subtype Utf16_String is String;
subtype Utf16_LE_String is Utf16_String;
subtype Utf16_BE_String is Utf16_String;
subtype Utf32_String is String;
subtype Utf32_LE_String is Utf32_String;
subtype Utf32_BE_String is Utf32_String;
Wide Strings are normaly not part if this. However my extension alows:
function From_Utf32
(Str : Unicode.CES.Utf32.Utf32_LE_String)
return Wide_String;
--
-- Return a new utf32-encoded string, from a standard Ada string.
--
function To_Utf32
(Str : Wide_String)
return Unicode.CES.Utf32.Utf32_LE_String;
------------------------------------------
-- Conversion to and from 8bit-encoding --
------------------------------------------
--
-- Return a new string, from 8 bit String encoded in codeset.
--
function From_Codeset (
Str : in String;
Codeset : in String)
return
Wide_String;
--
-- Return a new 8 bit String encoded in codeset.
--
function To_Codeset (
Str : in Wide_String;
Codeset : in String)
return
String;
-------------------------------------------
-- Conversion to and from UTF-8 encoding --
-------------------------------------------
--
-- Return a new string, from 8 bit String encoded in codeset.
--
function From_UTF8 (
Str : in String)
return
Wide_String;
--
-- Return a new 8 bit String encoded in codeset.
--
function To_UTF8 (
Str : in Wide_String)
return
String;
> function to_UTF8_String
> (s: Wide_String; substitute: Character := '#') return String is
No substitution. An exception is raised if it does not fit. If this is a
proble you might be better of raising a Utf32_String.
> result: String(1.. 4 * s'length);
> -- Unicode has at most 4 bytes for a UTF-8 encoded character
XML/Ada encodes full 32bit that is up to 6 UTF-8 bytes. In an other
discussion we allready figured out that this is not realy needed.
With Regards
Martin
--
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com
next prev parent reply other threads:[~2004-06-05 7:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-03 16:23 wide_string and assertions Georg Bauhaus
2004-06-04 3:37 ` Randy Brukardt
2004-06-04 8:49 ` Martin Krischik
2004-06-05 8:42 ` Pascal Obry
2004-06-05 17:15 ` Martin Krischik
2004-06-04 17:48 ` Georg Bauhaus
2004-06-05 7:10 ` Martin Krischik [this message]
2004-06-05 11:37 ` Georg Bauhaus
2004-06-05 17:11 ` Martin Krischik
2004-06-05 18:41 ` Björn Persson
2004-06-08 16:41 ` Georg Bauhaus
2004-06-09 13:19 ` Björn Persson
2004-06-09 15:03 ` Georg Bauhaus
2004-06-09 15:26 ` Björn Persson
2004-06-10 12:25 ` Georg Bauhaus
2004-06-10 13:30 ` Björn Persson
2004-06-05 12:32 ` China Björn Persson
2004-06-05 16:49 ` China, character sets Georg Bauhaus
2004-06-05 21:50 ` China Alexander E. Kopilovich
2004-06-04 20:42 ` wide_string and assertions Nick Roberts
2004-06-06 13:23 ` Björn Persson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox