StoneTable has asked for the wisdom of the Perl Monks concerning the following question:
Here's one that's been a persistent thorn in my side.
I'm trying to import some of my apache logs for statistical analysis. I get various bits of UTF-8 in there, either in the URI or the user-agent field. I've tried various hacks, such as running the text through tr, but I've never managed to solve this cleanly.
My locale is defined as UTF-8.
The database encoding is UTF8.
I have use UTF8;.
The error points to the text containing invalid UTF8 characters. What I'd like to do is truncate any invalid UTF8 characters, but I'm not sure how to go about that.
The error:
DBD::Pg::st execute failed: ERROR: invalid byte sequence for encoding "UTF8": 0xb0
I could ignore the errors, but I'm trying to batch insert the data. If it hits one of the invalid byte sequences, the entire transaction is rolled back. Not good, obviously.
What ways have you found to best handle/strip invalid UTF8 characters?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl and Postgresql: Invalid byte sequence for encoding "UTF8"
by ides (Deacon) on Dec 22, 2006 at 14:47 UTC | |
by StoneTable (Beadle) on Dec 23, 2006 at 18:59 UTC | |
by Anonymous Monk on Jun 17, 2009 at 12:04 UTC | |
|
Re: Perl and Postgresql: Invalid byte sequence for encoding "UTF8"
by ferreira (Chaplain) on Dec 22, 2006 at 13:10 UTC | |
|
Re: Perl and Postgresql: Invalid byte sequence for encoding "UTF8"
by diotalevi (Canon) on Dec 21, 2006 at 23:09 UTC | |
|
Re: Perl and Postgresql: Invalid byte sequence for encoding "UTF8"
by Fletch (Bishop) on Dec 21, 2006 at 21:31 UTC | |
|
Re: Perl and Postgresql: Invalid byte sequence for encoding "UTF8"
by Khen1950fx (Canon) on Dec 21, 2006 at 21:58 UTC |