Your ruby ββis in UTF-8 mode, but "\223"
not a valid UTF-8 string. When you are in UTF-8, any byte with an eighth bit means that you are in a multibyte character, and you need to continue reading more bytes to get the full character; this means that "\223"
is only part of the UTF-8 encoded character, hence your error.
0223 and 0224 (147 and 148 decimal) are smart quotes in the Windows-1252 set , but Windows-1252 isnβt UTF-8. In UTF-8, you want "\u201c"
and "\u201d"
for quotes:
>> puts "\u201c" " >> puts "\u201d" "
So, if you are trying to remove quotes, you will probably need one of them:
str.gsub("\u201c", "").gsub("\u201d", "") str.gsub(/[\u201c\u201d]/, '')
source share