[Gambas-user] Re: Using serial component for plc comunications

Benoit Minisini gambas at ...1...
Wed Jun 2 19:43:59 CEST 2004


On Wednesday 02 June 2004 16:47, Marcelo Duschkin wrote:
> El Mié 02 Jun 2004 10:36, Daniel escribió:
> |>  You have to convert the string using 'Conv$' function, which allows
> |> you to convert from UTF-8 to a lot of codifications, but you need to
> |> be sure what codification uses your device.
>
> In this particular case, there is no problem because the dataloggers are of
> my own design (I have the sources :))
>
> |>  However, if you add characters "by hand", I mean "Cadena=Cadena &
> |> chr(6) & chr(8)"... , each character added is just a byte, you've not
> |> to worry about UTF-8 or any other codification.
>
> What about the incoming chars? Are they converted to UTF8 ?
>

At the moment, no conversion occurs when reading from or writing to a stream. 
So incoming chars are encoded in the charset used by the sender.

It seems that UTF-8 = ASCII for Chr(0) to chr(127), so you can send chr(13), 
chr(10), ... without worrying.

Conv$() can convert from any charset to any other charset, provided the 
conversion is possible via the "iconv()" libc routine.

Another point:
 PRINT #Stream, "a string"; 
and
 WRITE #Stream, "a string", Len("a string")
are strictly equivalent.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list