UNABLE TO READ KOREAN LANGUAGE TO PRINT VALUES OR EXPORT REPORT INTO PDF FORMAT

HI Experts,

Name i have added french language displaying properly
billername i have added korean language displaying as ????
how to resolve this issue

try  {
			
			OutputStream out = new FileOutputStream("example.properties");
			Properties properties = new Properties();
			properties.setProperty("name", "Rapport de paiement de facture");
			properties.setProperty("billername", "\u767C\u55AE\u4EBA\u540D\u7A31");
			properties.setProperty("version", "1.0");			
			properties.store(out, "This is a sample for java properties");

		} catch (IOException e) {
			e.printStackTrace();
		}

		try  {
			
			BufferedReader in = new BufferedReader(
			   new InputStreamReader(
	                      new FileInputStream("example.properties"), "UTF8"));			
			Properties prop = new Properties();
			prop.load(in);			

			System.out.println("####Properties.stringPropertyNames usage####");
			for (String property : prop.stringPropertyNames()) {
				String value = prop.getProperty(property);
				System.out.println(property + "=" + value);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Open in new window



o/p:

####Properties.stringPropertyNames usage####
version=1.0
billername=?????                        //COMING AS ? INSTEAD OF KOREAN LANGUAGE
name=Rapport de paiement de facture
LVL 2
srikoteshAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
In the old days, Properties didn't support unicode without the use of tools. Not sure if that's still the case. But you don't write as UTF-8. Try that
For the purposes of the discussion, it will help if you can tell me the output of the following
System.out.println(System.getProperty("file.encoding"));

Open in new window

0
srikoteshAuthor Commented:
BufferedWriter out = new BufferedWriter(
					new OutputStreamWriter(new FileOutputStream("example.properties"), "UTF8"));
			Properties properties = new Properties();
			properties.setProperty("name", "Rapport de paiement de facture");
			properties.setProperty("billername", "\u767C\u55AE\u4EBA\u540D\u7A31");
			properties.setProperty("version", "1.0");
			properties.store(out, "This is a sample for java properties");

Open in new window


o/p of the example.properties file:

version=1.0
billername=發單人名稱
name=Rapport de paiement de facture

console p/p after reading the properties file:

####Properties.stringPropertyNames usage####
version=1.0
billername=?????
name=Rapport de paiement de facture
hello ####Properties.stringPropertyNames usage####
version=1.0
hello Cp1252
billername=?????
hello Cp1252
name=Rapport de paiement de facture


System.out.println(System.getProperty("file.encoding"));
O/P:
Cp1252
0
CEHJCommented:
Cp1252
Right, so your native character encoding doesn't support those Unicode characters. Therefore, you need to be certain that the app with which you're viewing the file is capable of reading that encoding. Just to make sure that the file IS as you want it, can you please attach it?
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

srikoteshAuthor Commented:
Hi CEHJ,

For sample code only i did file writing.
actually i don't need file writing concept.

directly i will read from properties:
whatever keys i need i will directly write in properties file and i will read in java program and export reports
while writing to file i am converting korean to unicode.

i will share the actual file
0
srikoteshAuthor Commented:
PFA...
0
srikoteshAuthor Commented:
0
CEHJCommented:
It would appear that UTF-8 is supported. What happens is that the props file gets written in Unicode escaped format. You can use the Korean characters directly in the code

properties.setProperty("billername", "發單人名稱");

Open in new window

and you'll get

billername=\u767C\u55AE\u4EBA\u540D\u7A31
0
srikoteshAuthor Commented:
Hi CEHJ,

I am not using any java code for writing properties file.(ignore my above sample java code)
whatever i shared as a attached file that is manually converted through native2ascii command

Can i set values of korean language directly with out doing conversion of unicode?

when i open the ko.txt file in notepad
under ecoding section-->it is showing as Encode in UTF-8 without BOM
0
CEHJCommented:
Can i set values of korean language directly with out doing conversion of unicode?

Yes. See above

when i open the ko.txt file in notepad
under ecoding section-->it is showing as Encode in UTF-8 without BOM
Well in that case, something is different going on for you. For me:
goose@t410:/tmp$ file ko.txt
ko.txt: ASCII text
goose@t410:/tmp$ cat ko.txt
text.billcategory=\u0e2b\u0e21\u0e27\u0e14\u0e2b\u0e21\u0e39\u0e48\u0e1c\u0e39\u0e49\u0e40\u0e23\u0e35\u0e22\u0e01\u0e40\u0e01\u0e47\u0e1a\u0e40\u0e07\u0e34\u0e19
text.billernme=\u0e0a\u0e37\u0e48\u0e2d\u0e1c\u0e39\u0e49\u0e43\u0e2b\u0e49\u0e1a\u0e23\u0e34\u0e01\u0e32\u0e23
goose@t410:/tmp$ xxd ko.txt 
0000000: 7465 7874 2e62 696c 6c63 6174 6567 6f72  text.billcategor
0000010: 793d 5c75 3065 3262 5c75 3065 3231 5c75  y=\u0e2b\u0e21\u
0000020: 3065 3237 5c75 3065 3134 5c75 3065 3262  0e27\u0e14\u0e2b
0000030: 5c75 3065 3231 5c75 3065 3339 5c75 3065  \u0e21\u0e39\u0e
0000040: 3438 5c75 3065 3163 5c75 3065 3339 5c75  48\u0e1c\u0e39\u
0000050: 3065 3439 5c75 3065 3430 5c75 3065 3233  0e49\u0e40\u0e23
0000060: 5c75 3065 3335 5c75 3065 3232 5c75 3065  \u0e35\u0e22\u0e
0000070: 3031 5c75 3065 3430 5c75 3065 3031 5c75  01\u0e40\u0e01\u
0000080: 3065 3437 5c75 3065 3161 5c75 3065 3430  0e47\u0e1a\u0e40
0000090: 5c75 3065 3037 5c75 3065 3334 5c75 3065  \u0e07\u0e34\u0e
00000a0: 3139 0a74 6578 742e 6269 6c6c 6572 6e6d  19.text.billernm
00000b0: 653d 5c75 3065 3061 5c75 3065 3337 5c75  e=\u0e0a\u0e37\u
00000c0: 3065 3438 5c75 3065 3264 5c75 3065 3163  0e48\u0e2d\u0e1c
00000d0: 5c75 3065 3339 5c75 3065 3439 5c75 3065  \u0e39\u0e49\u0e
00000e0: 3433 5c75 3065 3262 5c75 3065 3439 5c75  43\u0e2b\u0e49\u
00000f0: 3065 3161 5c75 3065 3233 5c75 3065 3334  0e1a\u0e23\u0e34
0000100: 5c75 3065 3031 5c75 3065 3332 5c75 3065  \u0e01\u0e32\u0e
0000110: 3233 0a                                  23.
goose@t410:/tmp$

Open in new window

0
krakatoaCommented:
You can test individual characters using

public static boolean isIdeographic(int codePoint)

of the Character class.

hth.
0
srikoteshAuthor Commented:
Hi Experts,

I have read the below java practices program
http://www.javapractices.com/topic/TopicAction.do?Id=257

this program identifying the BOM files and removing successfully.

but i didnt understand how it is remvoing bom files.//removeBOMs()
can some one help me how it is removing bom files.


Thanks
0
CEHJCommented:
What makes you think your problem is anything to do with your files containing a BOM? The files both you and i created with Properties are not even recognizably Unicode
If you really want to guard against any possibility of there being a BOM, then chain in a FilterReader such as https://github.com/yuyee/nettyserver/blob/master/common/src/com/git/original/common/bomfilter/BOMFilterReader.java when you invoke Properties.load
Here's an ideograph-free one:
https://developer.jasig.org/projects/resource-server/1.0.22-SNAPSHOT/apidocs/org/jasig/resource/aggr/BomFilterReader.html
0
srikoteshAuthor Commented:
Hi

even i set properties of korean language directly
it was not displaying properly while i export the reports

Any further suggestions

For exporting reports i am using ireports and invoking through java.
0
srikoteshAuthor Commented:
java code for invoking jasper report:

Date sdate = new Date();
			String sysDate = dateFormat.format(sdate);
			
			ireportshm.put("QUERY", reportQuery.toString());	//query to get the data from db		
			ireportshm.put("Debit_Amt", dbtAmt); 
			ireportshm.put("P_GENERATEDON", sysDate);			
			ireportshm.put(JRParameter.REPORT_LOCALE,
					IMProperties.getLocale(contexts.getLangId()));	//based on input language will be selected my case it is korean
			//here i am not setting any utf-8
			
			IOUtil.createParentDir(fdir + File.separator + groupId
					+ File.separator + userId + File.separator + fileName + "."
					+ fileType);
					
			jasperPrint = JasperFillManager.fillReport(
						Configurator.getInstance().get(
								prefix + pdfsuffix), ireportshm, conn);

Open in new window

0
CEHJCommented:
ireportshm.put("QUERY", reportQuery.toString());

Open in new window

Is that the actual content, including the Korean characters?
0
srikoteshAuthor Commented:
This is the actual content and properties file remains same whatever i shared earlier.
For pdf reports it is displaying in all languages(including korean language).
there is an option in reports we need to set the property like pdf encoding,i set it as Identity-H(Unicode)
Only i am facing the issue with csv reports.
0
CEHJCommented:
Only i am facing the issue with csv reports.
Right. I'm not familiar with Jasper. Are you producing the csv version with that?

I will remind you that your current platform encoding (Cp1252) cannot cope with Korean
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
krakatoaCommented:
Handled to the extent of the supplied information.
0
CEHJCommented:
:)
It would be useful to know exactly what you did to get UTF-8 in your csv
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.