Monday, June 23, 2008

MacRuby - String Transform

MacRuby 的 string 骨子裡是很多 CF String 的集合,但基於 ICU,所以可以如下進行 transform:

% macirb
>> s = "Domo"
=> "Domo"
>> s.class
=> NSCFString
>> puts s.transform("Latin-Hiragana")
ども
=> nil
>> 

這是來自 CFStringTransform 這個函式。原本是掛在 CFMutableString 這個 class 底下的 method,但在 MacRuby 裡面簡單整合進入其字串中,不必區分 mutable 與否。

關於 MacRuby, 見 http://ruby.macosforge.org/trac/wiki/MacRuby,有 binary package 可以抓下來試。

Labels: , ,


Comments: Post a Comment

Subscribe to Post Comments [Atom]



Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]