sql - Can't trim() Char(195) in MySQL -
i imported , in process of cleaning data exported older mainframe , have quite few lines start abnormal character (i.e. ascii characters 194, 195, 226, etc). can trim off of characters simple remainder = trim(leading '%' remainder)
(where '%' represents character in question.
the character won't removed 'Í'. if run remainder = trim(leading 'Í' remainder)
query won't find , trim character, if run ascii(remainder)
query on data shows character 195 strings start character.
next ran remainder = trim(leading char(195) remainder)
query , skipped character well.
why able remove else 1 character when mysql can convert it's ascii character code , doesn't have issues displaying character when normal select query run , applicable records displayed?
update have run following queries:
remainder = trim(leading convert('Í' using ascii) remainder) remainder = trim(leading convert('Í' using utf8) remainder) remainder = trim(leading convert(char(195) using ascii) remainder)
your query works correctly on mysql ( 5.5.44-0ubuntu0.14.04.1 ).
possibly reason doesn't work that, due character set mismatch, see character 195 is not character 195 @ all; might example 0xcd hex, or utf8 sequence corresponding 0xc38d hex, in case trimming 'Í' apparently transform in weirder.
try using hex() check character in question. it?
cd latin1 Í c38d utf8 Í <--- c3 char(195)
notice Í not char(195) @ all, 195 is beginning of Í in utf8.
in pinch, can perform operation... in hex.
select unhex(trim(leading 'c38d' hex('Íturalde'))); +---------------------------------------------------+ | unhex(trim(leading 'c38d' hex('Íturalde'))) | +---------------------------------------------------+ | turalde | +---------------------------------------------------+
this only ever trim leading c38d, or utf8 Í, while ignoring else.
update: may want dump table text file , try running recode
, iconv
or fixcode
on it.
Comments
Post a Comment