LoginSignup
5
6

More than 5 years have passed since last update.

全角英数 スペースを半角にする S-JIS 、UTF-8対応

Last updated at Posted at 2012-06-21

require 'nkf'
str=" unko うんこ!?lqrtv"

sjisの場合

res=NKF::nkf('-SsZ0',str)

utf-8の場合

res=NKF::nkf('-WwZ1',str)


output
res =>" unko うんこ!?lqrtv"
参考サイト
http://doc.ruby-lang.org/ja/1.9.2/class/NKF.html

5
6
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
5
6