comp.lang.ada
 help / color / mirror / Atom feed
* Re: String type conversions
  1999-02-09  0:00 String type conversions David Botton
  1999-02-09  0:00 ` Tucker Taft
  1999-02-09  0:00 ` Robert I. Eachus
@ 1999-02-09  0:00 ` Stephen Leake
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 1999-02-09  0:00 UTC (permalink / raw)


David Botton <David@Botton.com> writes:

> What is the best way to convert back forth between:
> 
> Wide_String to/from String

I'd define a map (Ada.Strings.Wide_Maps) to map non-ASCII characters
to ASCII.Nul or whatever might be appropriate, then write a loop to do
the actual copy from the map output character by character. Let the
compiler optimize the loop.

Or you can use Ada.Strings.Handling.To_Character in the loop, if you
don't need a full map.

> wchar_array to/from char_array

Convert to the Ada type, then proceed as above.

-- Stephe




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

* Re: String type conversions
  1999-02-09  0:00 String type conversions David Botton
  1999-02-09  0:00 ` Tucker Taft
@ 1999-02-09  0:00 ` Robert I. Eachus
  1999-02-12  0:00   ` Nick Roberts
  1999-02-09  0:00 ` Stephen Leake
  2 siblings, 1 reply; 5+ messages in thread
From: Robert I. Eachus @ 1999-02-09  0:00 UTC (permalink / raw)


In article <36C08E00.C3904670@Botton.com> David Botton <David@Botton.com> writes:

  > What is the best way to convert back forth between:

  > Wide_String to/from String

   Is this a trick question?  To convert from String to Wide_String is
easy, call Ada.Characters.Handling.To_Wide_String. ;-)  To go in the
other direction, there is a To_String function.  But what you may
really need is something with a better mapping for Wide_Characters not
in Character.  Note that you may want to make sure your Character type
is Latin-1 and not some other character set if you are using upper page
characters.

  > wchar_array to/from char_array

   Do I send you to the C newsgroup?  Or just tell you that there is
no Ada defined mapping from one to the other, and the actual mapping
will be OS and compiler specific.

   It is a shame that the character mapping arena is such a mess.
That is not an Ada issue, quite the opposite, in Ada it is a lot less
messy than in some other languages.  It is just that there are so many
standard, pseudo-standard, and non-standard character sets out there.


--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




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

* Re: String type conversions
  1999-02-09  0:00 String type conversions David Botton
@ 1999-02-09  0:00 ` Tucker Taft
  1999-02-09  0:00 ` Robert I. Eachus
  1999-02-09  0:00 ` Stephen Leake
  2 siblings, 0 replies; 5+ messages in thread
From: Tucker Taft @ 1999-02-09  0:00 UTC (permalink / raw)


David Botton wrote:
> 
> What is the best way to convert back forth between:
> 
> Wide_String to/from String

Ada.Characters.Handing.To_[Wide_]String

> wchar_array to/from char_array

As above, combined with To_Ada ... To_C.

> David Botton

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




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

* String type conversions
@ 1999-02-09  0:00 David Botton
  1999-02-09  0:00 ` Tucker Taft
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David Botton @ 1999-02-09  0:00 UTC (permalink / raw)


What is the best way to convert back forth between:

Wide_String to/from String
wchar_array to/from char_array

David Botton






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

* Re: String type conversions
  1999-02-09  0:00 ` Robert I. Eachus
@ 1999-02-12  0:00   ` Nick Roberts
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Roberts @ 1999-02-12  0:00 UTC (permalink / raw)


Before too long, hopefully, the answer will be "just don't use [8-bit]
Character". Most workstations and PCs these days are so powerful - in order
to cope with graphics, multimedia, games etc. - that having them handle
16-bit characters (instead of 8-bit/MBCS) most of the time is unlikely to be
a problem. And as for long-term file storage: compress.

Question: I am currently developing an idea as to a standard graphics/GUI
package hierarchy for Ada; would there be any point at all in providing a
(nearly duplicate) set of procedures and functions for the 'Character' type,
as well as for 'Wide_Character'?

-------------------------------------------
Nick Roberts    "The Prophylactic Didactic"
-------------------------------------------

Robert I. Eachus wrote in message ...
[...]
|   It is a shame that the character mapping arena is such a mess.







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

end of thread, other threads:[~1999-02-12  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-09  0:00 String type conversions David Botton
1999-02-09  0:00 ` Tucker Taft
1999-02-09  0:00 ` Robert I. Eachus
1999-02-12  0:00   ` Nick Roberts
1999-02-09  0:00 ` Stephen Leake

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