Created
January 11, 2010 23:40
-
-
Save mzsanford/274731 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
latin = "a" | |
arabic = [0xfeb6].pack('U') # Sheen, ش | |
cjk = [0x3333].pack('U') # HUIITO, ㌳ | |
kcodes = [ 'NONE', 'u', 's' ] | |
chars = [latin, arabic, cjk] | |
patterns = [ /\w/, /\W/, /[[:punct:]]/ ] | |
kcodes.each do |kcode| | |
$KCODE = kcode | |
puts "KCODE = #{kcode}" | |
patterns.each do |pattern| | |
puts " Pattern: #{pattern}" | |
chars.each do |char| | |
puts " #{char}: #{!!char.match(pattern)}" | |
end | |
end | |
end | |
# Output: | |
# | |
#KCODE = NONE | |
# Pattern: (?-mix:\w) | |
# a: true | |
# ﺶ: false | |
# ㌳: false | |
# Pattern: (?-mix:\W) | |
# a: false | |
# ﺶ: true | |
# ㌳: true | |
# Pattern: (?-mix:[[:punct:]]) | |
# a: false | |
# ﺶ: false | |
# ㌳: false | |
#KCODE = u | |
# Pattern: (?-mix:\w) | |
# a: true | |
# ﺶ: true | |
# ㌳: true | |
# Pattern: (?-mix:\W) | |
# a: false | |
# ﺶ: false | |
# ㌳: false | |
# Pattern: (?-mix:[[:punct:]]) | |
# a: false | |
# ﺶ: false | |
# ㌳: false | |
#KCODE = s | |
# Pattern: (?-mix:\w) | |
# a: true | |
# ﺶ: true | |
# ㌳: true | |
# Pattern: (?-mix:\W) | |
# a: false | |
# ﺶ: true | |
# ㌳: true | |
# Pattern: (?-mix:[[:punct:]]) | |
# a: false | |
# ﺶ: false | |
# ㌳: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment