Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created March 28, 2010 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igaiga/346654 to your computer and use it in GitHub Desktop.
Save igaiga/346654 to your computer and use it in GitHub Desktop.
utf-8 to utf-32
#!ruby -Ku
# -*- coding: utf-8 -*-
require 'nkf'
#str_u8 = 'apple'
str_u8 = 'いがいが'
str_u32 = NKF.nkf('-w32B0 -W',str_u8) # out: UTF-32(non BOM), in: UTF-8(non BOM)
str_u32.each_byte{ |b|
p b.to_s(16)
}
p str_u32.bytesize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment