REBOL 3.0

Loading Strings

Carl Sassenrath, CTO
REBOL Technologies
13-Feb-2008 16:34 GMT

Article #0005
Main page || Index || Prior Article [0004] || Next Article [0006] || 12 Comments || Send feedback

R3 needs a way to load strings that are encoded in various formats:

  • UTF-8 (default)
  • Latin-1
  • Any codepage map
  • UTF-16 LE
  • UTF-16 BE

And, we may also want to allow other UTF formats, but that is a subject of a different decision topic.

To decide:

What we need to decide is the specific function spec to use for loading strings.

Earlier, I proposed the use of load because that is it's primary purpose: the conversion of external data to an internal representation. That includes not only code, but also images, sounds, and text.

For example, to load a string that is in UTF-16LE format:

str: load/as data 'utf-16le

However, your feedback indicated that the use of load in this way was perhaps confusing and overloaded the function with too much capability. In addition, because load is now implemented as a mezzanine, it does not really solve the basic problem. A media loading method is required below its implementation.

Another idea was to use to with a refinement to indicate the format. For example:

str: to/as string! data 'utf-16le

However, I've reconsidered that method, because the additional refinement arguments span all instances of to over all datatypes. Not something we really want to do unless it is critical. This same considerations can be applied to make because it also applies to all datatypes.

So, now I'm opening it up to the group for suggestions.

Note also that there is an opposite topic, the output of strings, but let's just focus right now on this one area of loading strings.

12 Comments

REBOL 3.0
Updated 20-Jul-2013 - Edit - Copyright REBOL Technologies - REBOL.net