module ZhongwenTools::Fullwidth

Constants

FW_HW

Public Class Methods

fullwidth?(str) click to toggle source
# File lib/zhongwen_tools/fullwidth.rb, line 11
def self.fullwidth?(str)
  !halfwidth?(str) && to_halfwidth(str) != str
end
halfwidth?(str) click to toggle source

TODO: type checking.

# File lib/zhongwen_tools/fullwidth.rb, line 7
def self.halfwidth?(str)
  str[ZhongwenTools::Regex.fullwidth].nil?
end
to_halfwidth(str) click to toggle source
# File lib/zhongwen_tools/fullwidth.rb, line 15
def self.to_halfwidth(str)
  str.gsub(/(#{ZhongwenTools::Regex.fullwidth})/, ZhongwenTools::Fullwidth::FW_HW)
end