module ActiveSupport::Multibyte::Unicode
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_support/multibyte/unicode.rbs module ActiveSupport::Multibyte::Unicode def tidy_bytes: (String string, ?false force) -> String end
def compose(codepoints)
def compose(codepoints) codepoints.pack("U*").unicode_normalize(:nfc).codepoints end
def decompose(type, codepoints)
def decompose(type, codepoints) if type == :compatibility codepoints.pack("U*").unicode_normalize(:nfkd).codepoints else codepoints.pack("U*").unicode_normalize(:nfd).codepoints end end
def recode_windows1252_chars(string)
def recode_windows1252_chars(string) string.encode(Encoding::UTF_8, Encoding::Windows_1252, invalid: :replace, undef: :replace) end
def tidy_bytes(string, force = false)
Experimental RBS support (using type sampling data from the type_fusion
project).
def tidy_bytes: (String string, ?false force) -> String
This signature was generated using 1 sample from 1 application.
Passing +true+ will forcibly tidy all bytes, assuming that the string's
resulting in a valid UTF-8 string.
Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent
def tidy_bytes(string, force = false) return string if string.empty? || string.ascii_only? return recode_windows1252_chars(string) if force string.scrub { |bad| recode_windows1252_chars(bad) } end