Question

Write Japanese characters to CSV

Asked by: Tarsha20

In my JSP I am doing the following

 <head>

      
      <script type="text/javascript">
      
      var newWindow;
      function checkForCSVExport()
      {
            <%  
                  String results = (String) session.getAttribute("EXCEL_FB_DATA") ;
                  String URL = (String) Form.makeUrl(request,"/custom/jsp/search/load_csv.jsp");
                  if(null != results)
                  {
                        out.println(
                                    "newWindow=window.open(\""
                                    + URL
                                    + "\", \"export\", \"toolbar=no,menubar=no,width=200,height=200,resizable=no\");");
                  }
            
            %>
      }
      
      
      
</script>
</head>

the String results contain comma seperated values with Japanese characters in them. We need to write these Japanese characters to CSV. For this we have a JSP page called load_csv.jsp. Here are its contents

<%@ page contentType="application/csv; charset=UTF-8" %>
<%@ page import="com.components.search.SearchResultsFeedback"%>

<%
      String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
      String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
      response.setHeader("Content-Disposition", "attachment;filename=searchresult.csv");
%>
<%=strFBHdr%>
<%=strFBResults%>

this works fine for English characters but Japanese characters are displayed as junk characters in CSV. Please help.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-12-02 at 22:42:15ID23952385
Topics

Java Programming Language

,

Java Server Pages (JSP)

Participating Experts
3
Points
400
Comments
52

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. window.opener
    On my website when you click a URL, I wish for a pop-up window to provide a warning with and option to leave the current site or return to the site. What I setup worked at one time, but now when you click on the button to go back in history and close window produces an acce...
  2. window.open
    i have main window (a) from there im opening popup window(b) from the window B i want to open an another child window how can i do that... i'm using window.open but it overwrites the last popup window, is there a way i can open all windows in a seprate window instead of ov...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: TomasHelgiPosted on 2008-12-03 at 00:39:43ID: 23084135

   Hi!

Try changing the charset from UTF-8 to a Japanese charset.
<%@ page contentType="application/csv; charset=UTF-8" %>
                                                                   ----------------------            

Regards,
   Tomas Helgi

 

by: Tarsha20Posted on 2008-12-03 at 01:09:59ID: 23084285

I gave Shift_JIS but still it is giving unreadable characters for Japanese characters. However english characters continue to work fine.

 

by: TomasHelgiPosted on 2008-12-03 at 01:36:38ID: 23084397

And is your operating system configured correctly to handle Japanese characters ?

Regards,
   Tomas Helgi

 

by: CEHJPosted on 2008-12-03 at 01:40:18ID: 23084412

>>Japanese characters are displayed as junk characters in CSV.

Displayed where?

 

by: Tarsha20Posted on 2008-12-03 at 01:46:48ID: 23084444

>>Displayed where?
In the CSV. when I open it using excel, I see junk values

 

by: Tarsha20Posted on 2008-12-03 at 01:47:49ID: 23084448

>>And is your operating system configured correctly to handle Japanese characters ?
Yes it is, Japanese language pack is installed. Japanese characters display fine in Jsp pages and javascript alerts

 

by: CEHJPosted on 2008-12-03 at 01:49:20ID: 23084455

Can you post an example 'bad' file?

 

by: CEHJPosted on 2008-12-03 at 01:54:41ID: 23084485

Also, you might make that header into the following:

<%@ page pageEncoding="UTF-8" contentType="application/csv; charset=UTF-8" %>

                                              
1:

Select allOpen in new window

 

by: Tarsha20Posted on 2008-12-03 at 02:32:09ID: 23084657

Please change the extension to CSV and open it using excel. I had to change the extension and CSV was not getting uploaded.
3G and 3I columns contains examples of Japanese characters.

>><%@ page pageEncoding="UTF-8" contentType="application/csv; charset=UTF-8" %>
tried this, but same problem persists

 

by: CEHJPosted on 2008-12-03 at 03:34:16ID: 23084965

The central problem seems to be that CSV files normally have no support for Unicode. See

http://drupal.org/node/172996

In fact, there's nothing wrong with your file, but OpenOffice Calc (for one) simply refuses to open as UTF-8, despite the default encoding on my system being that anyway.

You might have more luck opening in Excel if you prepend a BOM (0xEF0xBB0xBF) to the file

 

by: Tarsha20Posted on 2008-12-03 at 03:42:30ID: 23085011

The same problem comes even if I try to save it as excel.
I did the following in my code

Now it is saved as an excel file but result is the same as far as Japanese characters are concerned.

<%@ page pageEncoding="UTF-8" contentType="application/vnd.ms-excel; charset=UTF-8" %>
 
<%
	String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
	String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
	response.setHeader("Content-Disposition", "attachment;filename=searchresul.xls");
%>
<%=strFBHdr%>
<%=strFBResults%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: Tarsha20Posted on 2008-12-03 at 03:51:24ID: 23085062


There is an interesting thing that I observed. If I right click on the CSV file and select "Open with --> Word" then the word application asks me
"Select the encoding that makes your document readable". If I select "Unicode (UTF-8)", Japanese characters appear perfectly fine. But why doesn't this happen in excel as that is also UTF-8 compliant  since I can type japanese characters into the same excel file.

 

by: CEHJPosted on 2008-12-03 at 03:54:30ID: 23085075

>>The same problem comes even if I try to save it as excel.

Well that doesn't really 'count' as it wasn't saved *by* Excel ;-)

Did you try the BOM trick i mentioned?

 

by: Tarsha20Posted on 2008-12-03 at 04:49:12ID: 23085378

>>You might have more luck opening in Excel if you prepend a BOM (0xEF0xBB0xBF) to the file

Can you please elaborate how to do that?

 

by: CEHJPosted on 2008-12-03 at 04:56:20ID: 23085411

Something like

final byte[] BOM = { (byte)0xEF, (byte)0xBB, (byte)0xBF };
out.write(BOM);
out.write(theOriginalFileBytes);
                                              
1:
2:
3:

Select allOpen in new window

 

by: Tarsha20Posted on 2008-12-03 at 05:24:10ID: 23085577

It gives me this
The method write(int) in the type Writer is not applicable for the arguments (byte[])

 

by: CEHJPosted on 2008-12-03 at 05:27:30ID: 23085599

If you're using the Writer, try writing the following instead:

final char[] BOM  = { 0xEF, 0xBB, 0xBF };

                                              
1:

Select allOpen in new window

 

by: Tarsha20Posted on 2008-12-03 at 05:34:27ID: 23085648

same problem, still csv show junk values

 

by: CEHJPosted on 2008-12-03 at 05:37:30ID: 23085675

Can you show me the code you used?

 

by: thomas908Posted on 2008-12-03 at 05:43:47ID: 23085724

 

by: thomas908Posted on 2008-12-03 at 05:44:40ID: 23085733

I am extremely sorry, the link is already there. Please ignore my post

 

by: Tarsha20Posted on 2008-12-03 at 05:45:55ID: 23085743


<%@ page contentType="application/csv; charset=UTF-8" %>
 
 
<%
	String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
	String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
	response.setHeader("Content-Disposition", "attachment;filename=searchresult(NEC).csv");
  	
	final char[] BOM  = { 0xEF, 0xBB, 0xBF };
	out.write(BOM);
	out.write(strFBHdr);
	out.write(strFBResults);
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:

Select allOpen in new window

 

by: CEHJPosted on 2008-12-03 at 05:56:19ID: 23085841

Try writing the BOM immediately before

out.write(strFBResults);

and you might also set the Content-Length and set it to strFBResults.length() + 3

 

by: Tarsha20Posted on 2008-12-03 at 06:43:55ID: 23086272

>>and you might also set the Content-Length and set it to strFBResults.length() + 3
can you please let me know where to set the content-length?

 

by: Tarsha20Posted on 2008-12-03 at 06:45:02ID: 23086289

>>Try writing the BOM immediately before
Doesn't help :(

 

by: CEHJPosted on 2008-12-03 at 07:42:05ID: 23086959

What happens when you try to open the attached csv file ?

  • bom.csv.txt
    • 42 bytes

    Remove .txt extension - what a bore all this ext stuff is!!

 

by: Tarsha20Posted on 2008-12-03 at 19:54:42ID: 23092543

It shows the Japanese characters correctly. This is what it displays

"r‰Lj            «¿«Ê"
"alpha            gamma"

 

by: Tarsha20Posted on 2008-12-03 at 19:55:43ID: 23092549

>>This is what it displays
They changed when I posted here, but they are correctly displayed in the csv you had send.

 

by: CEHJPosted on 2008-12-04 at 00:57:59ID: 23093525

Well that file was produced by following my own advice ;-)

 

by: Tarsha20Posted on 2008-12-04 at 01:28:32ID: 23093642

so what should I do now?

 

by: CEHJPosted on 2008-12-04 at 01:31:14ID: 23093660

Follow my advice? No seriously, do that and post the exact code you're using

 

by: Tarsha20Posted on 2008-12-04 at 02:01:03ID: 23093812

I had posted the exact code, that I was using.
this is the JSP being used for creating CSV


<%@ page contentType="application/csv; charset=UTF-8" %>
 
 
<%
	String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
	String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
	response.setHeader("Content-Disposition", "attachment;filename=searchresult.csv");
  	
	final char[] BOM  = { 0xEF, 0xBB, 0xBF };
 
	out.write(strFBHdr);
	out.write(BOM);
	out.write(strFBResults);
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:

Select allOpen in new window

 

by: Tarsha20Posted on 2008-12-04 at 02:04:32ID: 23093828

The above is being called from this JSP

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page errorPage="/wdk/errorhandler.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/dmform_1_0.tld" prefix="dmf"%>
<dmf:html>
<dmf:webform/>
<dmf:head>
	
	<script type="text/javascript">
 
	registerClientEventHandler(null,"checkForExcelExport",checkForExcelExport);
	
	var newWindow;
	function checkForExcelExport()
	{
		<%  
			String results = (String) session.getAttribute("EXCEL_FB_DATA") ;
			String URL = (String) Form.makeUrl(request,"/custom/jsp/search/load_csv.jsp");
			if(null != results)
			{
				out.println(
						"newWindow=window.open(\""
						+ URL
						+ "\", \"export\", \"toolbar=no,menubar=no,width=200,height=200,resizable=no\");");
			}
		
		%>
	}
</script>
</dmf:head>
 
<dmf:body> 
	<dmf:form>
	
	<%
	SearchResultsFeedback form = (SearchResultsFeedback)pageContext.getAttribute(Form.FORM, pageContext.REQUEST_SCOPE);
	DataProvider provider = ((Datagrid)form.getControl("fbSearchDataGrid",Datagrid.class)).getDataProvider();
	boolean bShowExportButton = true;
	%>
	
		<div id="search_results" style="absolute;display:inline;overflow: auto; width: 100%; height: 148px">
			<table cellspacing=0 cellpadding=0 border=0 width="100%" >
			
	<tr>
		<td width="100%" valign="top">
			<dmf:datagrid name="<%=IConstants.resultsDataGrid %>" paged='true' preservesort='false' width='100%' cellspacing='0' cellpadding='0' 
				bordersize='0' style='padding:0px'>
 
					<tr>
						<td width="100%" colspan=12 align=center>
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<dmf:row height='5' >
										<td align="center">
											<dmf:datapaging name='showItemsDdl' gotopageclass='doclistPager' />
										</td>
										<td>
											<dmf:label nlsid="MSG_SearchFbResults_019" cssclass="ShowItems"/>
											<dmf:label nlsid="MSG_SearchFbResults_020"/>
											<dmf:label label="<%=String.valueOf(form.isubmittedCount) %>"/>
											<dmf:label label=","/>
											<dmf:label nlsid="MSG_SearchFbResults_021"/>
											<dmf:label label="<%=String.valueOf(form.iRespondedCount) %>"/>
											<dmf:label label=","/>
											<dmf:label nlsid="MSG_SearchFbResults_022"/>
											<dmf:label label="<%=String.valueOf(form.iPendingCount) %>"/>
										</td>
										<td align='right' valign="top" class="ShowItems">
											<dmf:label name="showItemsLbl" nlsid='MSG_SearchFbResults_018'/>&nbsp;
											<dmf:datapagesize name='pageSizer'>
											</dmf:datapagesize>
										</td>
									</dmf:row>
								</tr>
							</table>
						</td>
					</tr>
			<!-- end -->
	
	
						
						<dmf:datagridTh cssclass="DTab" width="4%"/>
						<%
						if(provider.getResultsCount() == 0)
						{
							bShowExportButton = false;
						%>
						<dmf:nodataRow>
						<tr/><tr/><tr/><tr/>
							<td colspan="3">
								<dmf:label nlsid="MSG_SearchFbResults_003" style="font:bolder"/>
							</td>
						<tr/><tr/><tr/><tr/>
						</dmf:nodataRow>
 
						<%
						}
						
						%>
					</td>
				</tr>
			</dmf:datagrid>
		</table>
	</div>
	<%
	if(bShowExportButton)
	{
	%>
	<tr>
		<td>
			<dmf:button onclick="onClickExport" nlsid="MSG_SearchFbResults_002" runatclient="false" />
		</td>
	</tr>
	<%
	}
	%>
 
	</dmf:form>
 
</dmf:body>
</dmf:html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:

Select allOpen in new window

 

by: CEHJPosted on 2008-12-04 at 02:35:42ID: 23094001

What is the value of 'strFBHdr'?

 

by: Tarsha20Posted on 2008-12-04 at 04:10:34ID: 23094481

IT contains english characters which become part of CSV (as a header row).

 

by: CEHJPosted on 2008-12-04 at 04:18:43ID: 23094530

The length of that should be added to the content length (which i see you're still not setting)

 

by: Tarsha20Posted on 2008-12-04 at 04:45:04ID: 23094719

can you please let me know how to do that?

 

by: CEHJPosted on 2008-12-04 at 06:22:12ID: 23095481

response.setContentLength(contentLength);

 

by: Tarsha20Posted on 2008-12-04 at 19:53:08ID: 23102211

Still no change


<%@ page contentType="application/csv; charset=UTF-8" %>
 
 
<%
	String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
	String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
	response.setHeader("Content-Disposition", "attachment;filename=searchresult.csv");
  	
	final char[] BOM  = { 0xEF, 0xBB, 0xBF };
 
	response.setContentLength(strFBResults.length() + 3);
	out.write(strFBHdr);
	out.write(BOM);
	out.write(strFBResults);
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: CEHJPosted on 2008-12-05 at 01:07:23ID: 23103370

You're writing in the wrong order and not setting the length properly. Try

<%
        String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
        String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
        response.setHeader("Content-Disposition", "attachment;filename=searchresult.csv");
        
        final char[] BOM  = { 0xEF, 0xBB, 0xBF };
 
        response.setContentLength(strFBHdr.length() + strFBResults.length() + 3);
 
        out.write(BOM);
        out.write(strFBHdr);
        out.write(strFBResults);
	out.flush();
%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:

Select allOpen in new window

 

by: CEHJPosted on 2008-12-05 at 03:59:30ID: 23104108

CORRECTION! There's a problem with that because of the Writer, try instead

<%
        String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
        String strFBHdr = (String)session.getAttribute("EXCEL_FB_HEADER");
        response.setHeader("Content-Disposition", "attachment;filename=searchresult.csv");
        
        final byte[] BOM  = { (byte)0xEF, (byte)0xBB, (byte)0xBF };
 
        byte[] headerBytes = strFBHdr.getBytes();
        byte[] resultsBytes = strFBResults.getBytes();
        response.setContentLength(headerBytes.length + resultsBytes.length + BOM.length);
	OutputStream os = response.getOutputStream();
        os.write(BOM);
        os.write(headerBytes);
        os.write(resultsBytes);
	os.flush();
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: CEHJPosted on 2008-12-05 at 04:19:15ID: 23104202

One other thing - if your system's encoding is not UTF-8 by default, then you should call getBytes("UTF-8")

 

by: Tarsha20Posted on 2008-12-05 at 05:15:55ID: 23104499

how should I cal this?

 

by: CEHJPosted on 2008-12-05 at 06:00:55ID: 23104794

byte[] headerBytes = strFBHdr.getBytes("UTF-8");
                                              
1:

Select allOpen in new window

 

by: Tarsha20Posted on 2008-12-07 at 20:19:11ID: 23118743

I tried doing this but it shows just an object reference in the csv, rather than the result.

<%@ page contentType="application/csv; charset=UTF-8" %>
 
 
<%
	String strFBResults = (String)session.getAttribute("EXCEL_FB_DATA");
 
	response.setHeader("Content-Disposition", "attachment;filename=searchresult.csv");
  	
	final char[] BOM  = { 0xEF, 0xBB, 0xBF };
	byte[] resultBytes = strFBResults.getBytes("UTF-8");
 
	response.setContentLength(strFBResults.length()+3);
 
	out.write(resultBytes.toString());
%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:

Select allOpen in new window

 

by: CEHJPosted on 2008-12-08 at 02:02:51ID: 23119477

That's not what i suggested

 

by: Tarsha20Posted on 2008-12-08 at 03:07:34ID: 23119672

I am extremely sorry. Please let me know what should I be doing.

 

by: CEHJPosted on 2008-12-08 at 03:16:45ID: 23119700

Well i posted the code at http:#23104108

Apply the small correction i posted after that

 

by: Tarsha20Posted on 2008-12-08 at 04:04:37ID: 23119834

Thanks a lot, it works.
For my knowledge, can you please let me know what is this BOM and how did it solve the problem?

 

by: Tarsha20Posted on 2008-12-08 at 04:07:47ID: 23119852

If possible, please point me to some link/resource which gives more information about it.

 

by: Tarsha20Posted on 2008-12-08 at 04:22:26ID: 23119909

Thank you so much, I would have never ever figured it out by myself

 

by: CEHJPosted on 2008-12-08 at 04:49:48ID: 23120025

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...