Class: UniPropUtils::CodepointConverter
- Inherits:
-
Object
- Object
- UniPropUtils::CodepointConverter
- Defined in:
- lib/uniprop/utils.rb
Class Method Summary collapse
-
.str_to_int(codepoint_str) ⇒ Range<Integer,Integer>/Integer
String型のcodepointをIntegerを使用したオブジェクトに変換.
Class Method Details
.str_to_int(codepoint_str) ⇒ Range<Integer,Integer>/Integer
String型のcodepointをIntegerを使用したオブジェクトに変換
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/uniprop/utils.rb', line 523 def str_to_int(codepoint_str) if TypeJudgementer.validate_range_codepoint(codepoint_str) m = codepoint_str.match(/^([0-9A-Fa-f]{4,6})\.\.([0-9A-Fa-f]{4,6})$/) begin_codepoint = m[1] end_codepoint = m[2] return Range.new(begin_codepoint.hex, end_codepoint.hex) elsif TypeJudgementer.validate_single_codepoint(codepoint_str) return codepoint_str.hex else raise(ConvertError, "#{codepoint_str} is not a codepoint") end end |