haxe vs unicode (en)

23
Haxe × Unicode Ryusei Yamaguchi @mandel59

Upload: ryusei-yamaguchi

Post on 03-Aug-2015

299 views

Category:

Software


1 download

TRANSCRIPT

Haxe × UnicodeRyusei Yamaguchi @mandel59

Haxe Inoducon

looks like AconScript

with many features including…

paern matching

pe inference

generalized algebraic data pes

Various Targets

class Hello { public static function main() { trace("Hello, 世界🌏".length); } }

Hello, Unicode

What⁉

Target-dependent Behavior

class Hello { public static function main() { trace("Hello, 世界🌏".length); } }

1117 10

Internal Character Encoding Forms

A Я か 𩸽0000 0041

0000 042F 0000304B 00029E3D

0041 042F 304B D867 DE3D

41 D0 AF E3 81 8B F0 A9 B8 BD

Indexing Methods

By Code Points

A Я か 𩸽0 1 2 3

By Code Units (UTF-8)41 D0 AF E3 81 8B F0 A9 B8 BD

0 1 2 3 4 5 6 7 8 9

By Code Points

A Я か 𩸽0 1 2 3

By Code Units (UTF-8)41 D0 AF E3 81 8B F0 A9 B8 BD

0 1 2 3 4 5 6 7 8 9

Indexing Methods

s.substr(2, 2)

s.substr(3, 7)

SpecificaonsTarget Internal CEF IndexingMacro

UTF-8

By Code Units

C++NekoPHPFlash

UTF-16C#Java

JavaScriptPython 3 N/A By Code Points

Target Internal CEF IndexingHaxe Macro

UTF-8

By Code Units

C++NekoPHPFlash

UTF-16C#Java

JavaScriptPython 3 N/A By Code Points

Specificaons

11

17

10

How aboutthe present API?

Issue #3072Unicode support

https://github.com/HaxeFoundation/haxe/issues/3072#issue-34554043

haxe.Utf8

provides methods for UTF-8

indexing by code points

NOT ue cross platform API

haxe.Utf8

decode converts om UTF-8 to ISO-8859-1

encode converts oppositely

both have Sing -> Sing pe

haxe.Utf16

NOT IMPLEMENTED YET

haxe.Ucs2

UCS-2 is deprecated now

lack of surrogate pairs support

What called as “UCS-2” is actually potenally ill-formed UTF-16

We MUST support UTF-16

encode/decode model

Nave Sing haxe.Ucs2

decode

process

haxe.Ucs2

encode

Nave Sing

too complecated…hard to ansfer om legacy codes

Unifill

Unifill model

Nave Sing

process with Unifill methods

Nave Sing intuive!easy to ansfer

usable without knowledge

Unifill

using unifill.Unifill; class Hello { public static function main() { trace("Hello, 世界🌏”.uLength()); } }

1010 10

TODO

Propose Unifill to the Haxe API

Present API is insufficient

Refine the implementaon

Speed

Usabili

ank you!