Rebol3 Code Examplex


Unicode strings

Rebol [
    title: "Rosetta code: Unicode strings"
    file:  %Unicode_strings.r3
    url:   https://rosettacode.org/wiki/Unicode_strings
]

text: "你好"

foreach [title code][
    "text"                  [text        ]
    "codepoints"            [text/length ]
    "column width"          [text/width  ]
    "contains string 好"    [did find text  "好"]
    "contains character 平" [did find text #"平"]
][
    printf [-25 " : "][title attempt code]
]

Output:

                     text : 你好
               codepoints : 2
             column width : 4
       contains string 好 : true
    contains character 平 : false