Last active
December 16, 2015 12:58
-
-
Save Arie/5437870 to your computer and use it in GitHub Desktop.
active support tidy_byte monkey patch
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
#Given this input string, tidy_bytes explodes | |
#L 04/22/2013 - 19:56:11: "★radist★<14><STEAM_0:0:21110245><Red>" say_team "[P-REC] Çàïèñü ïîù¸ëú" | |
#This horrible monkey patch fixes it: | |
module ActiveSupport | |
module Multibyte | |
module Unicode | |
def tidy_byte(byte) | |
if byte.is_a? Integer | |
if byte < 160 | |
[database.cp1252[byte] || byte].pack("U").unpack("C*") | |
elsif byte < 192 | |
[194, byte] | |
else | |
[195, byte - 64] | |
end | |
else | |
byte | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment