comp.lang.ada
 help / color / mirror / Atom feed
* wide_string and assertions
@ 2004-06-03 16:23 Georg Bauhaus
  2004-06-04  3:37 ` Randy Brukardt
  0 siblings, 1 reply; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-03 16:23 UTC (permalink / raw)


AI-00286 present pragma assert with two arguments, one
of them a string. (Likewise, exceptions can be raised
"with a string"). I have some messages I want use as
the second argument. They contain characters outside
Latin-1. (And another 8bit character set won't do.)

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?

Has using Wide_String variants ever been considered? Or
is there just "no demand"?


-- Georg



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  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
                     ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Randy Brukardt @ 2004-06-04  3:37 UTC (permalink / raw)


"Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> wrote in message
news:c9nj9l$cif$1@a1-hrz.uni-duisburg.de...
> AI-00286 present pragma assert with two arguments, one
> of them a string. (Likewise, exceptions can be raised
> "with a string"). I have some messages I want use as
> the second argument. They contain characters outside
> Latin-1. (And another 8bit character set won't do.)
>
> 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.

> Has using Wide_String variants ever been considered? Or
> is there just "no demand"?

Ada.Exceptions only supports String for exception messages. Assert just uses
that existing mechanism for handling messages.

As far as demand goes, you're the first person to mention it to my
knowledge -- which is suggests that the demand is low. :-)

I'd like to see better support for UTF-8, but I don't think anything
sensible would really work in Assert (because the argument is static). Of
course, a function would work when raising with a message:
    raise Assert_Error with To_UTF_8 ("Wide_Wide_String");
so that might be preferable for this purpose. (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.)

                        Randy.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-04  3:37 ` Randy Brukardt
@ 2004-06-04  8:49   ` Martin Krischik
  2004-06-05  8:42     ` Pascal Obry
  2004-06-04 17:48   ` Georg Bauhaus
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 21+ messages in thread
From: Martin Krischik @ 2004-06-04  8:49 UTC (permalink / raw)


Randy Brukardt wrote:

> raiseᅵAssert_ErrorᅵwithᅵTo_UTF_8ᅵ("Wide_Wide_String");
> so that might be preferable for this purpose. (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.)

XML/Ada has support for UTF-8. XML/Ada can encode UTF-16 and UTF-32 as well.
All UTF formats are encoded it byte sequences aka in Strings and can
therefore be raised in exceptions.

If you need Wide_String support - I have some (not yet released) extensions
to XML/Ada for Wide_String support as well.

With Regards

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-04  3:37 ` Randy Brukardt
  2004-06-04  8:49   ` Martin Krischik
@ 2004-06-04 17:48   ` Georg Bauhaus
  2004-06-05  7:10     ` Martin Krischik
  2004-06-05 12:32     ` China Björn Persson
  2004-06-04 20:42   ` wide_string and assertions Nick Roberts
  2004-06-06 13:23   ` Björn Persson
  3 siblings, 2 replies; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-04 17:48 UTC (permalink / raw)


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?)

with Interfaces; use Interfaces;

package body support.utils is


   -- ----------------
   -- to_UTF8_String
   -- ----------------

   -- s UTF-8 encoded. '#' is a substitute for surrogate characters

   function to_UTF8_String
     (s: Wide_String; substitute: Character := '#') return String is

      result: String(1.. 4 * s'length);
      --  Unicode has at most 4 bytes for a UTF-8 encoded character

      k: Positive range result'range := result'first;
      --  in the loop, points to the first insertion position of a
      -- "byte sequence".

      bits: Unsigned_32 := 2#0#;
      --  the bits representing the Wide_Character

      subtype Ch is Character;
      --  abbreviation

      B6: constant := 2#111111#;

   begin

      for j in s'range loop
         bits := Wide_Character'pos(s(j));  -- XXX rename instead?


         if bits <= 2#1111111# then
            result(k) := Ch'Val(bits);
            k := k + 1;

         elsif bits <= 2#11111_111111# then
            result(k .. k + 1) :=
              (Ch'val(2#110_00000# or (shift_right(bits, 1 * 6) and 2#11111#)),
               Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
            k := k + 2;

         elsif bits in 16#d800# .. 16#dfff# then
            -- XXX surrogate characters vs UTF
            result(k) := substitute;
            k := k + 1;

         elsif
           bits = 16#fffe#
           or bits = 16#ffff#
         then
            -- ignore non-characters
            null;

         elsif bits <= 2#1111_111111_111111# then
            result(k .. k + 2) :=
              (Ch'val(2#1110_0000# or (shift_right(bits, 2 * 6) and 2#1111#)),
               Ch'val(2#10_000000# or (shift_right(bits, 1 * 6) and B6)),
               Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
            k := k + 3;

         elsif bits <= 2#111_111111_111111_111111# then
            result(k .. k + 3) :=
              (Ch'val(2#11110_000# or (shift_right(bits, 3 * 6) and 2#111#)),
               Ch'val(2#10_000000# or (shift_right(bits, 2 * 6) and B6)),
               Ch'val(2#10_000000# or (shift_right(bits, 1 * 6) and B6)),
               Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
            k := k + 4;

         else
            -- not Unicode
            raise Constraint_Error;

         end if;
      end loop;

      return result(1.. k - 1);

   end to_UTF8_String;




end support.utils;



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-04  3:37 ` Randy Brukardt
  2004-06-04  8:49   ` Martin Krischik
  2004-06-04 17:48   ` Georg Bauhaus
@ 2004-06-04 20:42   ` Nick Roberts
  2004-06-06 13:23   ` Björn Persson
  3 siblings, 0 replies; 21+ messages in thread
From: Nick Roberts @ 2004-06-04 20:42 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> wrote in message
news:47SdnXI-D-3icyLdRVn-uQ@megapath.net...

> "Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> wrote in
> message news:c9nj9l$cif$1@a1-hrz.uni-duisburg.de...
> > AI-00286 present pragma assert with two arguments, one
> > of them a string. (Likewise, exceptions can be raised
> > "with a string"). I have some messages I want use as
> > the second argument. They contain characters outside
> > Latin-1. (And another 8bit character set won't do.)
> >
> > 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.

That seems like a strange answer to me, on its own. Surely the answer must
be: yes, if the subsystem (run time system, operating system, development
environment, or whatever) that outputs the string can be expected to output
UTF-8 (or at least the UCS) correctly; otherwise, no (you must stick to
Latin-1). (Maybe this was meant to be implied.)

> > Has using Wide_String variants ever been considered? Or
> > is there just "no demand"?
>
> Ada.Exceptions only supports String for exception messages.
> Assert just uses that existing mechanism for handling messages.
>
> As far as demand goes, you're the first person to mention it to my
> knowledge -- which is suggests that the demand is low. :-)
>
> I'd like to see better support for UTF-8, but I don't think anything
> sensible would really work in Assert (because the argument is static). Of
> course, a function would work when raising with a message:
>     raise Assert_Error with To_UTF_8 ("Wide_Wide_String");
> so that might be preferable for this purpose. (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.)

I feel that implementations (for which it makes sense) could additionally
support alternatives to (NOT overloadings of)
Ada.Exceptions.Exception_Message/Name/Information, .Raise_Exception, and
pragma Assert with return values or parameters of type Wide_String (and/or
Wide_Wide_String) instead of String.

Maybe it would not be appropriate for such extensions to be mandated by the
primary standard (since they wouldn't be appropriate for many
implementations), but perhaps some kind of secondary or informal standard
might be a good idea.

As an aside, it might be worth just mentioning that the syntax:

   raise ... with ...;

is a proposed (and likely) extension of the raise statement for Ada 200X,
and not legal in the current Ada standard.

-- 
Nick Roberts





^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-04 17:48   ` Georg Bauhaus
@ 2004-06-05  7:10     ` Martin Krischik
  2004-06-05 11:37       ` Georg Bauhaus
  2004-06-05 12:32     ` China Björn Persson
  1 sibling, 1 reply; 21+ messages in thread
From: Martin Krischik @ 2004-06-05  7:10 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-04  8:49   ` Martin Krischik
@ 2004-06-05  8:42     ` Pascal Obry
  2004-06-05 17:15       ` Martin Krischik
  0 siblings, 1 reply; 21+ messages in thread
From: Pascal Obry @ 2004-06-05  8:42 UTC (permalink / raw)



Martin Krischik <krischik@users.sourceforge.net> writes:

> If you need Wide_String support - I have some (not yet released) extensions
> to XML/Ada for Wide_String support as well.

Are you going to consider proposing this extension for integration into
XML/Ada ?

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-05  7:10     ` Martin Krischik
@ 2004-06-05 11:37       ` Georg Bauhaus
  2004-06-05 17:11         ` Martin Krischik
  2004-06-05 18:41         ` Björn Persson
  0 siblings, 2 replies; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-05 11:37 UTC (permalink / raw)


Martin Krischik <krischik@users.sourceforge.net> wrote:
> 
:> (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.

I think I haven't actually, as the wheels are slightly different ;-)
There is also a small difference from how the same functionality
in available in GNAT, see below.
 I want to stay within standard Ada 95 in as many parts of the
program as possible. UTF-8 is so general, shouldn't support be
generally available, as Randy said. (The whole Mac OS X is all UTF-8,
and so was Plan 9, even before the rise of XML.)

 Now there is support for more than one XML library in my program.
Using either library's To_UTF_8 function, if available at all,
might introduce yet another issue to keep track of; they might have
differing semantics (raising exceptions or not, ...).

For example, how does XML/Ada treat Unicode characters in the range
16#D800# .. 16#DFFF#?   AFAICS, they are just treated like the other
Unicode_Char values.
(If I knew the details of current Unicode and ISO 10646 I could 
possibly answer my question: Will this work without surprises
in likely environments now and in the future (Mac, xterm -u8,
cmd.exe /u, ... or Unicode UI-windows)?

:   function To_UTF8 (
:      Str : in Wide_String)
:   return
:      String;

Is this available yet? (I guess it will extend Wide_Character values
into XML/Ada's mod 2**32 Unicode_Char and then pass the result through
the substitution chain?)


:>    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.

It is a problem as the UTF-8 strings are used in exception messages.
Raising an exception in To_UTF8 when raising another exception via

  Raise_Exception (excpt'Identity, To_UTF8 (msg));

does not seem helpful here?


:>       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.

Yes.


-- Georg



^ permalink raw reply	[flat|nested] 21+ messages in thread

* China
  2004-06-04 17:48   ` Georg Bauhaus
  2004-06-05  7:10     ` Martin Krischik
@ 2004-06-05 12:32     ` Björn Persson
  2004-06-05 16:49       ` China, character sets Georg Bauhaus
  2004-06-05 21:50       ` China Alexander E. Kopilovich
  1 sibling, 2 replies; 21+ messages in thread
From: Björn Persson @ 2004-06-05 12:32 UTC (permalink / raw)


Georg Bauhaus wrote:

> : 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?

Do the Chinese even use Ada? There seem to be mostly USers and Western 
Europeans here (and a Russian or two). This could be because the rest of 
the world don't use Usenet, because they're not so good at English, or 
because they're not interested in Ada.

I can imagine several irrational reasons why the Chinese wouldn't like 
Ada, but if they find its support for Chinese too incomplete, then 
that's one very rational reason. And they wouldn't be likely to come 
here and ask for it.

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: China, character sets
  2004-06-05 12:32     ` China Björn Persson
@ 2004-06-05 16:49       ` Georg Bauhaus
  2004-06-05 21:50       ` China Alexander E. Kopilovich
  1 sibling, 0 replies; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-05 16:49 UTC (permalink / raw)


Bj�rn Persson <spam-away@nowhere.nil> wrote:
:> : 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?
: 
: Do the Chinese even use Ada?

Rumor on c.l.ada has it that yes, GNAT is used there.
But even if not, it seems to be used (and supported?) in Japan.
How about South Korea? Taiwan?

: There seem to be mostly USers and Western 
: Europeans here (and a Russian or two).

Let's not again split Poland between East and West ;-)
If you want to write a Polish or Russian name next to a French
name, you are in trouble with 8bit character sets...
 
: if they find its support for Chinese too incomplete, then 
: that's one very rational reason.

At least if we apply western rationality ;-)



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-05 11:37       ` Georg Bauhaus
@ 2004-06-05 17:11         ` Martin Krischik
  2004-06-05 18:41         ` Björn Persson
  1 sibling, 0 replies; 21+ messages in thread
From: Martin Krischik @ 2004-06-05 17:11 UTC (permalink / raw)


Georg Bauhaus wrote:

> :   function To_UTF8 (
> :      Str : in Wide_String)
> :   return
> :      String;
> 
> Is this available yet?

If you know how to use cvs: Yes. Development is currently archived in AdaCL.

> (I guess it will extend Wide_Character values 
> into XML/Ada's mod 2**32 Unicode_Char and then pass the result through
> the substitution chain?)

I principle yes. But I shortcut for performance - that is I don't use an
UTF32_String in the middle.

> :>    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.
> 
> It is a problem as the UTF-8 strings are used in exception messages.
> Raising an exception in To_UTF8 when raising another exception via
> 
>   Raise_Exception (excpt'Identity, To_UTF8 (msg));
> 
> does not seem helpful here?

The To_Utf8 will not raise an exception - only the From_UTF8. So no problem
here.
 
With Regards

Martin.

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-05  8:42     ` Pascal Obry
@ 2004-06-05 17:15       ` Martin Krischik
  0 siblings, 0 replies; 21+ messages in thread
From: Martin Krischik @ 2004-06-05 17:15 UTC (permalink / raw)


Pascal Obry wrote:

> Martin Krischik <krischik@users.sourceforge.net> writes:
> 
>> If you need Wide_String support - I have some (not yet released)
>> extensions to XML/Ada for Wide_String support as well.
> 
> Are you going to consider proposing this extension for integration into
> XML/Ada ?

Yes. I already send the first batch to libre. However, libre did not answer.

I begin to fear that libre is a closed shop not taking in small patches.

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  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
  1 sibling, 1 reply; 21+ messages in thread
From: Björn Persson @ 2004-06-05 18:41 UTC (permalink / raw)


Georg Bauhaus wrote:

> Martin Krischik <krischik@users.sourceforge.net> wrote:
> 
> : As I said the functions are based on the Unicode part of XML/Ada. Not point
> : reinventing the Wheel.
> 
> I think I haven't actually, as the wheels are slightly different ;-)

I'm inventing wheels too. My wheel is spherical so it rolls in all 
directions. ;-)

I just finished a first, limited version of a library that might be of 
interest here. I call it EAstrings, for encoding-aware strings. It keeps 
track of how each string is encoded and transcodes them automatically 
when necessary. It uses Iconv for transcoding, so it supports all 
encodings that Iconv supports (and that's a *lot* on my Fedora box).

My aim is to make it possible to use it almost as a drop-in replacement 
for both Unbounded_String and Unbounded_Wide_String. Many operations 
aren't implemented yet, but here are some things you can already do:

    EA_1, EA_2     : EAstrings.EAstring;
    UTF_8_String   : EAstrings.Byte_Sequence :=
                       (49, 32, 226, 130, 172, 32, 226, 137, 160);
    Latin_1_String : String := "price: 1 £";
    UCS_2_String   : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
    ...
    EA_1 := EAstrings.To_EAstring(UTF_8_String, "UTF-8");
    EA_2 := EAstrings.Latin_1.To_EAstring(Latin_1_String);
    EAstrings.Append(EA_1, EAstrings.Tail(EA_2, 4));
    UCS_2_String := EAstrings.UCS_2.To_Unbounded_Wide_String(EA_1);

One drawback is that it only works on Unix (and probably only fairly 
modern Unixes). I hope to get it ported to Windows some day.

For those who want to have a look, I have uploaded the files to 
http://rombobeorn.webhop.net/eastrings (only temporarily, so don't link 
there).

There are also wrappers for Ada.Command_Line.Command_Name and 
Ada.Command_Line.Argument that return EAstrings correctly marked with 
the encoding that is used in the environment. I have vague plans for 
more wrappers for subprograms that take String parameters that may be 
interpreted as some other encoding than Latin 1. There's no wrapper for 
exceptions yet, but here's a way an exception could be raised with a 
message from an EAstring:

    Ada.Exceptions.Raise_Exception
      (The_Error'Identity,
       EAstrings.Byte_Sequence_To_Fake_String
         (EAstrings.Bytes
            (EAstrings.Transcode(EAstring_Message,
                                 EAstrings.OS.OS_Encoding))));

This would convert the message to whichever encoding is set in the 
environment.

(Transcode can raise exceptions, but a wrapper for Raise_Exception could 
of course catch those.)

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: China
  2004-06-05 12:32     ` China Björn Persson
  2004-06-05 16:49       ` China, character sets Georg Bauhaus
@ 2004-06-05 21:50       ` Alexander E. Kopilovich
  1 sibling, 0 replies; 21+ messages in thread
From: Alexander E. Kopilovich @ 2004-06-05 21:50 UTC (permalink / raw)
  To: comp.lang.ada

Bj?rn Persson wrote:

>Do the Chinese even use Ada?
No doubt they do, but you possibly can't find an example - because all
probable uses are either inside a secret military-related project or by
offshore contractor working for some Western company.

>I can imagine several irrational reasons why the Chinese wouldn't like 
>Ada, but if they find its support for Chinese too incomplete, then 
>that's one very rational reason.

Insufficient support for national alphabet never was an obstacle for use of
a programming language (I can assure you that all mainstream programming
languages flourished in Soviet Union and then Russia without any particular
support for Cyrillic). And anyway, Ada's support for national alphabets isn't
weaker than that of C++ (I hope you don't doubt that Chinese use C/C++ -:) .




Alexander Kopilovich                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia





^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-04  3:37 ` Randy Brukardt
                     ` (2 preceding siblings ...)
  2004-06-04 20:42   ` wide_string and assertions Nick Roberts
@ 2004-06-06 13:23   ` Björn Persson
  3 siblings, 0 replies; 21+ messages in thread
From: Björn Persson @ 2004-06-06 13:23 UTC (permalink / raw)


Randy Brukardt wrote:

>>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.
> 
> 
>>Has using Wide_String variants ever been considered? Or
>>is there just "no demand"?
> 
> 
> Ada.Exceptions only supports String for exception messages. Assert just uses
> that existing mechanism for handling messages.
> 
> As far as demand goes, you're the first person to mention it to my
> knowledge -- which is suggests that the demand is low. :-)

Isn't Ada 200Y going to allow anything that Unicode classifies as 
alphanumeric in identifiers? Being able to include the name of a type or 
variable in an exception message sounds like a good idea. Or the name of 
another exception, when one exception is raised because another 
exception was recieved.

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-05 18:41         ` Björn Persson
@ 2004-06-08 16:41           ` Georg Bauhaus
  2004-06-09 13:19             ` Björn Persson
  0 siblings, 1 reply; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-08 16:41 UTC (permalink / raw)


Bj�rn Persson <spam-away@nowhere.nil> wrote:
: One drawback is that it only works on Unix (and probably only fairly 
: modern Unixes). I hope to get it ported to Windows some day.

This might become usefule, thanks!
There is also a small dependence on GNAT (errno), I guess
this is easy to adjust to other compilers?
 
-- Georg



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-08 16:41           ` Georg Bauhaus
@ 2004-06-09 13:19             ` Björn Persson
  2004-06-09 15:03               ` Georg Bauhaus
  0 siblings, 1 reply; 21+ messages in thread
From: Björn Persson @ 2004-06-09 13:19 UTC (permalink / raw)


Georg Bauhaus wrote:

> There is also a small dependence on GNAT (errno), I guess
> this is easy to adjust to other compilers?

Making it work on all compilers without manual editing could be 
difficult. I think a get_errno function would have to be added to 
eastrings_unix_interface.c, and I don't know how portable that would be 
to different C libraries. In my opinion it's unfortunate that there is 
no errno in Interfaces.C.

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-09 13:19             ` Björn Persson
@ 2004-06-09 15:03               ` Georg Bauhaus
  2004-06-09 15:26                 ` Björn Persson
  0 siblings, 1 reply; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-09 15:03 UTC (permalink / raw)


Bj�rn Persson <spam-away@nowhere.nil> wrote:
: Georg Bauhaus wrote:
: 
:> There is also a small dependence on GNAT (errno), I guess
:> this is easy to adjust to other compilers?
: 
: Making it work on all compilers without manual editing could be 
: difficult.

Maybe configuring a separately compiled unit before translation?



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-09 15:03               ` Georg Bauhaus
@ 2004-06-09 15:26                 ` Björn Persson
  2004-06-10 12:25                   ` Georg Bauhaus
  0 siblings, 1 reply; 21+ messages in thread
From: Björn Persson @ 2004-06-09 15:26 UTC (permalink / raw)


Georg Bauhaus wrote:

> Björn Persson <spam-away@nowhere.nil> wrote:
> : Georg Bauhaus wrote:
> : 
> :> There is also a small dependence on GNAT (errno), I guess
> :> this is easy to adjust to other compilers?
> : 
> : Making it work on all compilers without manual editing could be 
> : difficult.
> 
> Maybe configuring a separately compiled unit before translation?

Sorry, I don't follow. What translation?

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-09 15:26                 ` Björn Persson
@ 2004-06-10 12:25                   ` Georg Bauhaus
  2004-06-10 13:30                     ` Björn Persson
  0 siblings, 1 reply; 21+ messages in thread
From: Georg Bauhaus @ 2004-06-10 12:25 UTC (permalink / raw)


Bj�rn Persson <spam-away@nowhere.nil> wrote:
:> 
:> Maybe configuring a separately compiled unit before translation?
: 
: Sorry, I don't follow. What translation?

Compilation, I meant.  When I have an OS/compiler specific subprogram
I try to wrap it in an "interface package", and use a renaming.
A simplified example is,

with Unix_File_System;
package File_System renames Unix_File_System;

Then I can use subprograms from File_System without knowing what
the actual file system is. However, I have to make sure, before
translation of the program, that the unit file_system renames the correct
file system package before I start the compiler.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: wide_string and assertions
  2004-06-10 12:25                   ` Georg Bauhaus
@ 2004-06-10 13:30                     ` Björn Persson
  0 siblings, 0 replies; 21+ messages in thread
From: Björn Persson @ 2004-06-10 13:30 UTC (permalink / raw)


Georg Bauhaus wrote:

> Björn Persson <spam-away@nowhere.nil> wrote:
> :> 
> :> Maybe configuring a separately compiled unit before translation?
> : 
> : Sorry, I don't follow. What translation?
> 
> Compilation, I meant.  When I have an OS/compiler specific subprogram
> I try to wrap it in an "interface package", and use a renaming.

Yes, that's one way to do it. I saw there was a discussion some time ago 
on how to do these things in the absence of conditional compilation.

> However, I have to make sure, before
> translation of the program, that the unit file_system renames the correct
> file system package before I start the compiler.

Exactly, and to that end you can write a shell script for Unix and a 
batch file for Windows that figure out the right configurations in the 
most common cases.

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2004-06-10 13:30 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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