Created
June 25, 2016 09:39
-
-
Save LuPoYi/587166f38c460d982601a42f6cdaaecf to your computer and use it in GitHub Desktop.
英數字半形轉全形
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_to_wide_word(text) | |
text.gsub(/[a-v]/){|a|(a.ord + 41608).chr('big5').encode('utf-8')} | |
.gsub(/[w-z]/){|a|(a.ord + 41673).chr('big5').encode('utf-8')} | |
.gsub(/[A-Z]/){|a|(a.ord + 41614).chr('big5').encode('utf-8')} | |
.gsub(/[0-9]/){|a|(a.ord + 41599).chr('big5').encode('utf-8')} | |
end | |
> convert_to_wide_word("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
=> "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL | |
MNOPQRSTUVWXYZ" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment