-1

I have a CSV file which contains Korean characters which has to be written in oracle database.

When I read the CSV with 'fgetcsv' I don't see the Korean characters instead it looks like:

(image)

My PHP file header is set to "UTF-8" and the db NLS_CHARACTERSET = AL32UTF8.

How do I solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • What do you mean by *"when I read the CSV"*? Reading doesn't typically show anything so how are you viewing what you read? – Phil Jul 12 '16 at 06:21
  • This is always worth reading too ~ http://stackoverflow.com/questions/279170/how-to-support-utf-8-completely-in-a-web-application (ignore the DB parts) – Phil Jul 12 '16 at 06:23
  • I have used this code to read the CSV file and just print them `code` while (($data = fgetcsv($handle, $delimiter)) !== FALSE) { Here i am printing the value } – Niki Jackson Jul 12 '16 at 06:26
  • Code goes in your question, not in the comments. Is your output in an HTML document? If so, is it being delivered with a UTF8 charset and / or with [``](http://stackoverflow.com/a/285036/283366) in the ``? How **exactly** are you *"printing the value"*? – Phil Jul 12 '16 at 06:31
  • Yes the output is HTML document. and the meta charset is utf-8. I have opened the CSV file with fgetcsv and putting it in the loop and trying to take each column and print them with echo (to test whether i am getting korean character) – Niki Jackson Jul 12 '16 at 06:58
  • if youve found the solution, answer your own question and accept it. changing your title to 'solved' doesnt help anyone. – DevDonkey Jul 12 '16 at 13:43

1 Answers1

1

(Posted on behalf of the OP).

Your PHP page should be rendered as UTF-8 character set to view the Korean (in my case) character for that mb_string variables has to be set as UTF-8 as follows.

        mb_internal_encoding('UTF-8');
        mb_http_output('UTF-8');
        mb_http_input('UTF-8');
        mb_language('uni');
        mb_regex_encoding('UTF-8');
        ob_start('mb_output_handler');

and then there should be a environment variable has to be placed as follows:

        PutEnv("NLS_LANG=AMERICAN_AMERICA.AL32UTF8");

Finally convert the string to UTF-8 with mb_convert_encoding:

        mb_convert_encoding($str, "UTF-8", "EUC-KR");

We are done.

halfer
  • 19,824
  • 17
  • 99
  • 186