LoginSignup
1
2

More than 5 years have passed since last update.

XojoでUnicode正規化

Last updated at Posted at 2014-12-28

XojoでUnicode正規化をするメソッドです。
XojoにはNSStringクラスがないのですけど、CFStringRefで代用できるんですね。
String型からとくに変換する必要もないので、かなり便利。


Function toNFC (s as String) As String
  // NFCの場合

  If s.LenB=0 then Return ""

  Declare function precomposedStringWithCanonicalMapping lib "Cocoa" selector "precomposedStringWithCanonicalMapping" (targetStr as CFStringRef) as CFStringRef

  Return precomposedStringWithCanonicalMapping(s)
End Function

4種類の正規化形式は以下の通り。
* NFC -> precomposedStringWithCanonicalMapping
* NFD -> decomposedStringWithCanonicalMapping
* NFKC -> precomposedStringWithCompatibilityMapping
* NFKD -> decomposedStringWithCompatibilityMapping

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2