1

I have a form which contains several fields like textbox, lables, etc. In text fields I used "Kruti Dev 040 Wide" font to type value in Hindi, But when i save this value to database its shown in English. Please help me out of this problem I want this values in database in Hindi format.

Thanks and regards Sandeep Sharma

Nick Holt
  • 33,455
  • 4
  • 52
  • 58
Sandy
  • 15
  • 1
  • 8
  • Does your data base support `Hindi` font. – AJ. Feb 12 '14 at 08:44
  • 1
    By "english" you mean ascii chars? It's not translating the text automatically, right? Are you using unicode text encoding? – Fildor Feb 12 '14 at 08:44
  • The font is irrelevant for storage. Did you type devanagari or latin characters in the text field? – Joni Feb 12 '14 at 08:45
  • @Fildor that would be kind of awesome and creepy at the same time – Philipp Sander Feb 12 '14 at 08:45
  • database I have to use is MySql database – Sandy Feb 12 '14 at 08:45
  • @PhilippSander That's exactly what I thought :D – Fildor Feb 12 '14 at 08:46
  • AJ. yes it can supports Hindi Fonts. When I am using Google IME its work fine but when i do same directly it doesn't work – Sandy Feb 12 '14 at 08:47
  • Fildor... I am not using unicode text encoding. How i can use it give me some example – Sandy Feb 12 '14 at 08:48
  • 2
    Could you perhaps put a more relevant title on this question? That would enable any people who have similar problems in the future to find this question more easily. – Dawood ibn Kareem Feb 12 '14 at 08:50
  • @DavidWallace The problem with that is probably that the OP does not know, what his problem actually is. – Fildor Feb 12 '14 at 08:51
  • 2
    As a guess I'd say you haven't set the character encoding on the MySQL JDBC driver to be UTF-8. – Nick Holt Feb 12 '14 at 08:54
  • @Fildor Yeah, the OP's problem is that they want to save Hindi text to their database, and they're getting English instead (or more accurately, getting Roman characters instead of whatever the Hindi script is called). We don't know why yet, but it must be possible to be more accurately descriptive than "Java Swing Programming Questions". – Dawood ibn Kareem Feb 12 '14 at 08:54
  • What is the charset of your database? In order to save hindi charset must be UTF-8 – Sanjeev Feb 12 '14 at 08:56
  • 1
    http://stackoverflow.com/questions/12435867/how-to-store-the-data-in-unicode-in-hindi-language – Sanjeev Feb 12 '14 at 09:00
  • @Fildor you should got my question correctly. But what can i do dont know the solution. How to get Hindi string in mysql database instead of English(Roman) – Sandy Feb 12 '14 at 09:03
  • @user3300665 Follow Sanjeev's link. I think the answer there is _exactly_ what you need. – Fildor Feb 12 '14 at 09:05
  • @Sanjeev I have default charset in my database it is "UTF-8". – Sandy Feb 12 '14 at 09:05
  • @Fildor Sanjeev's link is of php and mysql, but i have to work with java and mysql – Sandy Feb 12 '14 at 09:06
  • @user3300665 please follow the link i posted. it will give you what you want. – Sanjeev Feb 12 '14 at 09:07
  • 1
    I just checked. That particular font actually puts Hindi characters at the standard codepoints for Roman characters. So saving in Roman characters is exactly what you'd expect to happen, regardless of the character set that the database uses. If you want to display text that you pull out of your database as Hindi, you'll need to use the same font to display it. – Dawood ibn Kareem Feb 12 '14 at 09:08
  • @Sanjeev you wright code for php but i used java then how to change charset in java code? – Sandy Feb 12 '14 at 09:09
  • @Sandy it's not a charset issue. – Dawood ibn Kareem Feb 12 '14 at 09:10
  • If what David wrote is true (+1 by the way) you should check that first before touching your DB Tables and all. @DavidWallace you should make that comment an answer. – Fildor Feb 12 '14 at 09:11
  • Yeah, it's true. I'll try and turn it into an answer forthwith. – Dawood ibn Kareem Feb 12 '14 at 09:12

1 Answers1

1

Normally, you'd expect to have to set up your database to store UTF-8, in order to use Devanagari characters (the ones used for Hindi). But the Kruti Dev fonts avoid this issue by doing something slightly nasty. They actually make the Roman letters look like the Devanagari letters. This has the advantage that you can easily type Hindi on a standard English keyboard. But it has the disadvantage that anything that you write in Hindi will, under the covers, be Roman text.

So you have two options.

  1. You can use a Kruti Dev font, but be aware that you'll still be working with Roman text. If you want to display your text, and have it look like Hindi, you'll need to use a Kruti Dev font to display it.

  2. You can abandon the Kruti Dev font, and use UTF-8 characters for the Devanagari characters; making sure, of course, that your database is able to save UTF-8.

Dawood ibn Kareem
  • 77,785
  • 15
  • 98
  • 110
  • Your answer will help me somewhat to understand what "Kruti Dev" font will do. But I have to save those values in hindi in database. Please find any converter or any function that should help me out – Sandy Feb 12 '14 at 09:51