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?
 
CEHJConnect With a Mentor Commented:
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
 
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
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
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.