Ruby/String/unicode
Материал из Wiki.crossplatform.ru
Версия от 17:56, 13 сентября 2010; ViGOur (Обсуждение | вклад)
Содержание |
a string literal containing a multibyte multiplication character
s = "2×2=4" puts s
Greek lowercase pi
"\u{A5}" # => "¥": same as "\u00A5" "\u{3C0}" # Greek lowercase pi: same as "\u03C0" "\u{10ffff}" # The largest Unicode codepoint
leading zeros cannot be dropped
"\u00D7" "\u20ac"
The string contains 6 bytes which encode 5 characters
s = "2×2=4" s.length # => 5: Characters: "2" "×" "2" "=" "4" s.bytesize # => 6: Bytes (hex): 32 c3 97 32 3d 34
Unicode string
money = "\u{20AC A3 A5}" # => "€£¥" money = "\u{20AC 20 A3 20 A5}" # => "€ £ ¥"