unicode - Remove four byte UTF-8 characters in classic ASP/VBScript (MySQL related) -


i've spent 18 hours of trying different things , searching around now, give , have ask guys.

backstory: migrating old ms access database mysql (version 5.6.16-log).

problem: unicode text in access database contain 4 bytes (utf-8).

mysql still has problem inserting 4 bytes utf-8 characters. problem getting old , surprised discover it's not fixed yet: http://bugs.mysql.com/bug.php?id=67297

i'm using "mysql odbc 5.3 unicode driver" transfer data between databases (the latest beta development release). no matter try process ends freezing when try insert string 4 byte utf8 characters (the thread uses 100% cpu forever). have tried workarounds suggested everywhere on internet, nothing works.

now accept limitations of mysql: can't store unicode characters.

so want remove 4 byte utf8 characters text before insert database. can't life of me find way in classic asp.

can help?

(i can't not use asp btw, there way code rewrite in different language. changing databases remarkable feat; there several of them , take days complete.)

edit: solution in jscript acceptable, since can run asp pages.

this should work:

function utf8filter(strstring)     on error resume next     = 1 len(strstring)          charcode = ascw(mid(strstring, i, 1))         if charcode > 32 or charcode <= 127             'append valid character'             strstring = mid(strstring, i, 1)         end if     next      utf8filter = strstring     on error goto 0 end function 

updated function:

function remove4byteuft8(strstring)     set objregex = createobject("vbscript.regexp")     objregex.global = true        objregex.ignorecase = true     objregex.pattern = "/[\xf0-\xf7].../s"      remove4byteuft8 = objregex.replace(strstring, "") end function 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -