Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

search for farsi string in mysql

  Asked By: Bailey    Date: Dec 21    Category: Java    Views: 1074
  

i have a table in mysql which its encoding like its whole collumns
encoding is utf-8 as my database character set.
I have farsi string in some collumns(which are originally migrated from
MSSQL Server)character encoding of farsi strings is utf8 but what is
visible in mysql table is sth other than farsi characters(i see sth
like this "فردوس") however when i fetch these strings from db and
save them with ANSI encoding into a page(html page) which its character
encoding is utf8(<meta http-equiv="content-type" content="text/html;
charset=UTF-8"/>)farsi characters are visible and everything goes OK.
problem araises when i want to search for a string from my page which
its encoding is utf8 in db (e.g. search
for "تهران"), here no results return
from DB .

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Renee Lane     Answered On: Dec 21

From what I remember you have to specify the encoding  in your jdbc connection

Like:
jdbc:mysql://localhost/some_db?useUnicode=yes&characterEncoding=UTF-8

 
Answer #2    Answered By: Volney Fischer     Answered On: Dec 21

You should execute these 2 queries after connecting to database  ,

SET CHARACTER set  UTF8
SET NAMES 'utf8'

(before any select statement.)
and another point is that it is better to set your column's collation
to utf8_persian_ci for achieving desired ordering result.

 
Didn't find what you were looking for? Find more on search for farsi string in mysql Or get search suggestion and latest updates.




Tagged: