Re: String?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Rolf wrote:

> Hi 'string fans'!

smile

> As I know, a character is a byte that represents a human readable or
> printable symbol. A character string (synonymous: string) is a series of
> characters. i.e., a series of bytes representing human readable|printable
> symbols (words, sentences,...).

Again: I never heard or read, that the definition of "character" or
"string" depends on the question, whether or not something is printable.
E.g. in BASIC, this is clearly *not* the case. You might also want to
look here:
   http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?characters
   http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?string

Of course, under certain circumstances, it is useful to know, whether or
not a given string is printable, but it has nothing got to do with its
*definition*.

> Is it important to differentiate between a general byte series (#00 to #FF)
> and a 'string'?

No, this is the same.

> 1) If there are 256 readable|printable symbols assigned to the
>    numbers #00 to #FF, then it's impossible do decide, if you have a
>    'string' or not!
>
> 2) If you declare at least one byte not to be a readable|printable
>    symbol, then you may declare any byte series of this type as a 'string' in
>    comparison to a generally byte series, which may contain any byte between
>    #00 and #FF. In C, i.e., #00 is assumed to be such a byte, and therefore
>    a byte series ending with the byte #00 is declared as such a type of
>    string (Null terminated string). This makes sense only for specially
>    written 'string handling routines' (stringcmp(), printf(),...), nothing
>    else.
>
> 3) For I know what I would like to read|write|print, Euphoria gives you the
>    opportunity to decide, what you would like to handle as a 'string' or not.
>    In practice I don't see any necessity to have a so called string type, it
>    makes no real sense. However, if you believe you need it, then use a
>    type function similar like that, what Nicholas Koceja has given as an
>    example.

Like him, you are missing the point.
Using such a user-defined string type doesn't solve the problem: If a
Euphoria program reads e.g. {74,111,104,110} from a file, there is no way
to find out, whether this sequence  means "John", or the weight of the
members of my family, or whatever.

Surely any string has to be a sequence of special integers (which can be
checked by such a user-defined type), but not any such sequence is a
string!

Regards,
   Juergen

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu