From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2afae4a128914036 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: wide_string and assertions Date: Sat, 05 Jun 2004 09:10:55 +0200 Organization: AdaCL Message-ID: <1224046.crrTJmpIeA@linux1.krischik.com> References: <47SdnXI-D-3icyLdRVn-uQ@megapath.net> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1086420281 06 25614 ons+GEtr2UMz2Ts 040605 07:24:41 X-Complaints-To: usenet-abuse@t-online.de X-ID: VUZ4YsZfreUJ25RqqWWCWLIXjkBtIjm4Wb8VRwVymbGK6cfywZ-Bk6 User-Agent: KNode/0.7.7 Xref: g2news1.google.com comp.lang.ada:1116 Date: 2004-06-05T09:10:55+02:00 List-Id: Georg Bauhaus wrote: > Randy Brukardt wrote: > : "Georg Bauhaus" 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