Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Re[2]: utf8-encode

From: oliva:david:seznam:cz at: 14-Jun-2002 10:35

Hello Romano, 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 1.2.1.3.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> ][ 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> ] RPT> ) RPT> :h RPT> skip RPT> ] RPT> ] RPT> head h RPT> ] RPT> --- RPT> Ciao RPT> Romano 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.