tag:blogger.com,1999:blog-691739770978360344.post2931621375137855334..comments2023-03-16T02:22:53.208-07:00Comments on KWizCom SharePoint Blog: UTF-8 with signature?Igor Goldshtaubhttp://www.blogger.com/profile/11454162751899721014noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-691739770978360344.post-20446798534388293522011-05-12T09:18:04.172-07:002011-05-12T09:18:04.172-07:00Hi Grégoire,
I think you did not understand the p...Hi Grégoire,<br /><br />I think you did not understand the problem, or I do not understand you answer.<br /><br />The problem here is with writing it to the page response stream object, not my own StreamWriter.<br /><br />Am I missing something?<br /><br />Thanks.Shai Petelhttps://www.blogger.com/profile/15299015261603781984noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-155101112423198882011-05-11T11:03:22.205-07:002011-05-11T11:03:22.205-07:00Hi you can also do this :
StreamWriter sw = new S...Hi you can also do this :<br /><br />StreamWriter sw = new StreamWriter(fileNameAndpath, true, Encoding.UTF8);<br /><br />sw.Write(sb.ToString());<br /><br />etc... <br /><br />It will add the three byte order mark automaticaly in the beginning of the file.<br /><br />Grégoire LafortuneAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-69774612344756252792011-02-04T19:12:25.045-08:002011-02-04T19:12:25.045-08:00PERFECT! Thanks!PERFECT! Thanks!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-54425151240550575162010-12-28T04:32:24.874-08:002010-12-28T04:32:24.874-08:00Thanks Shai...
It helped me very much.
Roi K :)<b>Thanks Shai...</b><br />It helped me very much.<br />Roi K :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-28085471878818085822009-11-27T08:19:34.274-08:002009-11-27T08:19:34.274-08:00Many thanks for this. Helped me enormously exporti...Many thanks for this. Helped me enormously exporting csv's from PHP.<br /><br />For any PHP'ers who come this way, you need to output the following at the very start of your file:<br /><br />echo chr(0xEF).chr(0xBB).chr(0xBF);<br /><br />Thanks again :-)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-25231428812174261292009-07-17T05:56:48.298-07:002009-07-17T05:56:48.298-07:00I manage to solve that problem in classic ASP. We ...I manage to solve that problem in classic ASP. We have to convert string to binary object. ASP can work with binary data thanks to ADO Stream.<br /><br />This is example how to do that:<br /><br />[code]<br />' This function convert text to binary object<br />Function StringToBinary(Text, CharSet)<br /> <br /> Const adTypeText = 2<br /> Const adTypeBinary = 1<br /> <br /> 'Create Stream object<br /> Dim BinaryStream 'As New Stream<br /> Set BinaryStream = CreateObject("ADODB.Stream")<br /> <br /> 'Specify stream type - we want To save text/string data.<br /> BinaryStream.Type = adTypeText<br /> <br /> 'Specify charset For the source text (unicode) data.<br /> If Len(CharSet) > 0 Then<br /> BinaryStream.CharSet = CharSet<br /> Else<br /> BinaryStream.CharSet = "UTF-8" ' it can be us-ascii, utf-8 ...<br /> End If<br /> <br /> 'Open the stream And write text/string data To the object<br /> BinaryStream.Open<br /> BinaryStream.WriteText Text<br /> <br /> 'Change stream type To binary<br /> BinaryStream.Position = 0<br /> BinaryStream.Type = adTypeBinary<br /> <br /> 'Ignore first two bytes - sign of<br /> BinaryStream.Position = 0<br /> <br /> 'Open the stream And get binary data from the object<br /> StringToBinary = BinaryStream.Read<br /> <br />End Function<br /><br /><br />' This is you string<br />csv = "id;name;something"<br /><br />Response.ContentType = "text/csv"<br />Response.AddHeader "Content-Disposition", "attachment; filename=filename.csv"<br /> <br />binary_object = StringToBinary(csv, "UTF-8")<br />Response.BinaryWrite(binary_object)<br /> <br />Response.End<br />[/code]<br /><br />I hope that helps. It works for me.Unknownhttps://www.blogger.com/profile/13118607179372247409noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-68965712734339163172009-07-17T05:46:35.642-07:002009-07-17T05:46:35.642-07:00This comment has been removed by the author.Unknownhttps://www.blogger.com/profile/13118607179372247409noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-1128734663311729522009-07-17T04:14:13.145-07:002009-07-17T04:14:13.145-07:00Please excuse my ignorance, but how do I "run...Please excuse my ignorance, but how do I "run" the C# code on my Excel spreadsheet, so that it will give me Unicode in the csv file I export to? Or did tjodalv get an answer in vba that I could use???Faszikamhttps://www.blogger.com/profile/05900183293110649441noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-46592735552711825302009-07-15T14:42:40.407-07:002009-07-15T14:42:40.407-07:00Awesome! I've been beating my head on the desk...Awesome! I've been beating my head on the desk for hours about this one.whatispunkhttps://www.blogger.com/profile/01799137374846984183noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-66484571889275191612009-07-10T04:56:47.328-07:002009-07-10T04:56:47.328-07:00Can you tell me how to do that in classic ASP. I h...Can you tell me how to do that in classic ASP. I have the same problem there.<br /><br />Plese help. You can write comment or send me to zvonimir@idea.hrUnknownhttps://www.blogger.com/profile/13118607179372247409noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-10088514914324929772009-06-09T09:17:37.083-07:002009-06-09T09:17:37.083-07:00Thanks a lot for the info... I was getting despera...Thanks a lot for the info... I was getting desperate regarding this problem and that 3 byte sig solved my problemwarlockPThttps://www.blogger.com/profile/07070051312921900101noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-49031627145133415782009-02-12T05:03:00.000-08:002009-02-12T05:03:00.000-08:00Thanks a lot for the tip.Thanks a lot for the tip.Jan Aagaardhttps://www.blogger.com/profile/00265105596343387502noreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-76682031385935384552009-01-07T16:36:00.000-08:002009-01-07T16:36:00.000-08:00I'm glad you found this googling. I tried for a wh...I'm glad you found this googling. I tried for a while and ended up stumbling on the solution myself after having saved the file as utf-8 in notepad and comparing the two.<BR/><BR/>For some reason excel like my utf saved in notepad file but not the original and after doing a hex comparison, I noticed the three signature bytes and started adding them in the original output.<BR/><BR/>All works great now!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-691739770978360344.post-50516846767195175312007-12-12T07:23:00.000-08:002007-12-12T07:23:00.000-08:00Hi, This article really helped me, when creating a...Hi, <BR/><BR/>This article really helped me, when creating a .htm file on the fly in a web application.<BR/><BR/>Thanx a lot!Anonymousnoreply@blogger.com