[REBOL] Re: Re: utf8-encode
From: oliva:david:seznam:cz at: 14-Jun-2002 10:35
Wednesday, June 12, 2002, 11:36:51 PM, you wrote:
>> or this shorter and faster version but not so clear to understand:
RPT> And this is mine (more fast and more criptic :-)
RPT> I do not know utf8, i copied the logic of your code.
RPT> This works also under actual View 126.96.36.199.1
RPT> I think parse is the best way to go.
RPT> utf8-encode: func[
RPT> "Encodes the string data to UTF-8"
RPT> str [any-string!] "string to encode"
RPT> /local c h
RPT> ;if you remove 'copy you can change the original string
RPT> parse/all copy str [
RPT> any [
RPT> h: skip (
RPT> if 127 < c: first h [
RPT> h: change h c / 64 or 192
RPT> insert h c and 63 or 128
RPT> head h
Great.... I have to say... you are the winner:-) I did some tests and
your code is the fastest. If you don't mind I will upload the script
to the library.