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 5970273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:21:04+00:00 2026-05-22T20:21:04+00:00

In my database, I have the following entry id | name | info 1

  • 0

In my database, I have the following entry

id     |      name      |      info
1          John Smith         Çö ¿¬¼

As you can tell, the info column displays wrong — it’s actually Korean, though.
In Chrome, when I switch the browser encoding from UTF-8 to Korean (‘euc-kr’, I think), I actually manage to view the text as such:

id     |      name      |      info
1          John Smith        횉철 쩔짭쩌

I then manually copy the text into the info in the database and save, and now I can view it in UTF-8, without switching my browser’s encoding.

Awesome. Now I’d like to get that same thing done in Rails, not manually. So starting with the original entry again, I go to the console and type:

require 'iconv'
u = User.find(1)
info = u.info
new_info = Iconv.iconv('euc-kr','UTF-8', info)
u.update_attribute('info', new_info)

However, what I end up with is something resembling \x{A2AF}\x{A8FA}\x{A1C6} \x{A2A5}\x{A8A2} in the database, not 횉철 쩔짭쩌.

I have a very basic understanding of unicode and encoding.

Can someone please explain what’s going on here and how to get around that?
The desired result is what I achieved manually.

Thanks!

  • 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-22T20:21:05+00:00Added an answer on May 22, 2026 at 8:21 pm

    Wow. I’m beating myself over the head now. After hours of trying to resolve this, I finally figured it out myself a few minutes after I posted a question here.

    The solution consists of three simple steps:

    STEP 1:

    I almost had it right. I shouldn’t be converting from euc-kr to utf-8, but the other way around, as such:

    Iconv.iconv('UTF-8', 'euc-kr', info)
    

    STEP 2:

    I might still run into some errors in the text, so to be safe I tell Iconv to ignore any errors:

    Iconv.iconv('UTF-8//IGNORE', 'euc-kr', info)
    

    Finally, I actually get REAL KOREAN TEXT, yay!
    The problem is, when I try to insert it into the database, it’s still inserting something along the lines of:

    UPDATE `users` SET `info` = '--- \n- \"\\xEC\\xB2\\xA0\\xEC\\xB1\\x8C...' etc...
    

    Even though it turns out I have the right text. So why is that? Onto the last step.

    STEP 3:

    Turns out the output from Iconv is an array. And so, we merge it with join:

    Iconv.iconv('UTF-8//IGNORE', 'euc-kr', info).join
    

    And this actually works!

    The final code:

    require 'iconv'
    u = User.find(1)
    info = u.info
    new_info = Iconv.iconv('UTF-8//IGNORE','euc-kr', info).join
    u.update_attribute('info', new_info)
    

    Hope this helps whomever sees this (and knowing myself, probably future me).

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

Sidebar

Related Questions

I have the following entry in my database: t.time :my_time_stamp In my controller I
In my mysql database I have the following information in a page name field.
I have the following tables in my database that have a many-to-many relationship, which
I am using the SQLite database and have the following persistent class (simplified): public
I have following data to save in database using php my data is :
I have no control over database schema and have the following (simplified) table structure:
I have a database where I store objects. I have the following (simplified) schema
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have the following problem in a Database using Access 2007 as front end
I have the following tables in a database (i'll only list the important attributes):

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.