- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 03:58 AM
Hi,
I'm writing a function in a script include that exports me some data and adds it as an Attachment to a record.
Example Code is like this
var data = "Name;Firstname;Phone";
data += "\n";
data += "Bauer;Sven;+492408xxx";
data += "\n";
data += "Meier;Karl-Heinz;+492408xxx";
data += "\n";
data += "Müller;Joachim;+492408xxx";
var company = new GlideRecord('core_company');
company.get('ee4fab735f6512006d8ddb765a069c99');
var attachment = new GlideSysAttachment();
var newFile = attachment.write(company, 'Telefonliste.csv', 'text/csv', data);
My Problem now is that the Attachment is encoded in UTF-8 but without BOM.
This makes the Umlaut 'ü' to not be shown correctly in Excel.
Any Ideas how to change the Enocoding to ANSI or add the bom-Marker?
Sven
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 10:57 PM
Hi Sven,
I just had the same issue. Unfortunately UTF-8 hates all special characters, even if this encoding should happily display them.
I have tried encoded/decoding into UTF-8 characters, without success.
But I have some good news, and this may be a little hacky but it works for me:
Add "\uFEFF" right at the start of the content.
This is the character encoding for BOM.
So in your case:
var data = "\uFEFFName;Firstname;Phone";
data += "\n";
data += "Bauer;Sven;+492408xxx";
data += "\n";
data += "Meier;Karl-Heinz;+492408xxx";
data += "\n";
data += "Müller;Joachim;+492408xxx";
var company = new GlideRecord('core_company');
company.get('ee4fab735f6512006d8ddb765a069c99');
var attachment = new GlideSysAttachment();
var newFile = attachment.write(company, 'Telefonliste.csv', 'text/csv', data);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 04:09 AM
Hi Sven,
I think by default ServiceNow encodes characters in UTF-8 format.
Not sure whether any other character set can be user or not.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 09:18 AM
Hello Ankur,
I encounter the same problem. Attachments that have characters like ä,ö,ü are not shown correctly. Is there no possible in ServiceNow to solve this problem?
Best regards,
Felipe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 10:37 PM
Hi Felipe,
Not sure on this part. If I get any details will post here.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 01:53 AM
The similar issue:
in datasource: CSV (with BOM) attachment. Import: the first column always broken (BOM included to the first column name)...
How to import CSV-file with BOM attachment correctly?