[REBOL] Re[2]: utf8-encode
From: oliva:david:seznam:cz at: 12-Jun-2002 14:16
or this shorter and faster version but not so clear to understand:
rebol [
title: "UTF-8 encode"
purpose: {Encodes the string data to UTF-8}
author: "oldeS"
email: [oliva--david--seznam--cz]
date: 7-Jun-2002/0:24:44+2:00
usage: {
>> utf8-encode "chars: ìšèøžýáíé"
== "chars: ìšèøžýáÃé"}
comment: {More info: http://czyborra.com/utf/ }
]
utf8-encode: func[
"Encodes the string data to UTF-8 (from Latin-1)"
str [any-string!] "string to encode"
/local c
][
str: to binary! str
forall str [
if 127 < c: first str [
change str to char! (c and 63 or 128)
c: enbase/base to binary! to char! c 2
remove/part tail c -6
c: head insert/dup head c #"0" 6
str: insert str (#{c0} or debase/base c 2)
]
]
to string! head str
]
Now just to find how to encode Latin2 charset to have real czech
chars:(