Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6202449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:44:13+00:00 2026-05-24T04:44:13+00:00

I have UTF-8 text data from Twitter (so it my be very dirty). When

  • 0

I have UTF-8 text data from Twitter (so it my be very dirty). When input into mysql (database char set is utf8) some text get garbaged. I would like a way to clean data before putting it in.

Insert ignore search_tweets set id_str = 'pass1',text = 'RT @youpon_info: Youponです!この度はキャンペーン参加ありがとうございました。たくさんの方々にキャンペーンに参加して頂きました。'  ;
Insert ignore search_tweets set id_str = 'fail',text = 'RT @youpon_info: Youponです!この度はキャンペーン参加ありがとうございました。たくさんの方々にキャンペーンに参加して頂きました。また次のキャンペーンをすぐに予定しております!もう少'  ;
Insert ignore search_tweets set id_str = 'pass2',text = 'また次のキャンペーンをすぐに予定しております!もう少'  ;

fail.text = pass1.text + pass2.text and they both go in and come out of mysql fine. fail comes out as

RT @youpon_info: Youponã§ãï¼ãã®åº¦ã¯ã­ã£ã³ãã¼ã³åå ãããã¨ããããã¾ãããããããã®æ¹ã

I have done this with direct MySQL calls, although originally it was all done in Ruby datamapper and direct calls.

I would like to know how to clean the data so it goes in/comes out of MySQL the same. If possible a ruby solution would be nice but just knowing how to clean it would great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:44:13+00:00Added an answer on May 24, 2026 at 4:44 am

    It looks like the data being truncated. Do you have enough room in the text column for the data you are inserting?

    I suspect varchar(n) will only accept n bytes, not n characters and the Japanese characters take at 3 bytes each. Mysql is known for silently truncating data that don’t fit in and if it happens to be truncated in the middle of UTF-8 character, the reader may decide it’s not correct UTF-8 and interpret it as ISO8859-1, which would result in what you are seeing.

    Note, that in UTF-8, all characters of living languages fit in 3 bytes (with Chinese, Japanese and Korean all being in those that always need all 3) and the extended symbols and historical scripts need 4 bytes. So to stay on the safe side, the database must be willing to accept 4 times as many bytes as there are characters allowed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables here - one is in UTF and holds Arabic text
I'm looking for a general strategy/advice on how to handle invalid UTF-8 input from
I have some simple SOAP client to get data from WSDL and display it.
I have a Tapestry application, that retrieves data from a form, writes it to
I'm using VS 2008 and need to read text files that have UTF-8 Chinese
I'm stuck to getting data from this xml: <?xml version=1.0 encoding=UTF-8?> <document> <AAA>Header</AAA> <BBB>
I have some code to retrieve XML data: import cStringIO import pycurl from xml.etree
i have this site structure: First page: <script src=../jquery.uniform.min.js type=text/javascript charset=utf-8></script> <script type=text/javascript charset=utf-8>
I have a text file that is formatted like JSON, but in a print/view
I need to write model data ( CharField s only) to an XML file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.