Sha256: 769198fd5b494b23b0bfdeeed573ae8978f3c047537871769cb3e90fd912ce0b
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
# Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 class TwitterCldr.Component to_utf8 : (codepoints) -> unless codepoints instanceof Array codepoints = [codepoints] (@to_hex(cp) for cp in codepoints) to_hex : (codepoint) -> if (codepoint >= 0 and codepoint <= 0xD7FF or codepoint >= 0xE000 and codepoint <= 0xFFFF) return @to_escaped_hex(codepoint) else if (codepoint >= 0x10000 and codepoint <= 0x10FFFF) codepoint -= 0x10000 first = ((0xffc00 & codepoint) >> 10) + 0xD800 second = (0x3ff & codepoint) + 0xDC00 return @to_escaped_hex(first) + '+' + @to_escaped_hex(second) to_escaped_hex : (codepoint) -> s = codepoint.toString(16) s = "0000".slice(0, 4 - s.length) + s return "\\u" + s; range_to_regex : (range) -> if range.first instanceof Array @array_to_regex(range) else "[" + @to_utf8(range.first) + "-" + @to_utf8(range.last) + "]" array_to_regex : (arr) -> ("(?:" + @to_utf8(c) + ")" for c in arr).join("") set_to_regex : (set) -> strs = ((@._set_element_to_regex(element) ) for element in TwitterCldr.Utilities.remove_duplicates( set.to_array(true)) ) ("(?:" + strs.join("|") + ")") _set_element_to_regex : (element) -> if element instanceof TwitterCldr.Range @range_to_regex(element) else if element instanceof Array @array_to_regex(element) else @to_utf8(element)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter_cldr_js-2.4.0 | lib/twitter_cldr/js/mustache/parsers/unicode_regex/component.coffee |