cancel
Showing results for 
Search instead for 
Did you mean: 

SAP UI5, unicode and national (non-ASCII) characters

lucam_shamat
Participant

Dear collective wisdom,

I'm fighting against what looks like a potentially silly issue since too long, so I decided to bother this community and ask for your informed help.

We've started developing a solution on SAP Cloud Platform since just a few months and having a strange issue.

Our solution (written in JavaScript and running natively on the SAP Cloud Platform) calls the Facebook API using web services written and run as .xsjs code; the Facebook API returns specific posts, potentially in non-english languages (German and its ä, ö, ü, ß is very common).

We then reads the returned JSON objects, transform them with .asString() and JSON.parse() them before writing the posts and a few values in HANA tables.

Everything works perfectly with English, it is NOT working with all non-ASCII characters, thou.

When we display the posts in SAP UI5 using GenericTile and sap.m.Text content, we always get "corrupted" non-ASCII characters, i. e. in a form similar to: "Wusstest du, dass der lateinische Name von Rosmarin �Tau des Meeres� bedeutet? Dieser poetische Name kommt von der Herkunftsregion des aromatischen Strauchs, dass vor allem an den Küsten des Mittelmeeres wächst."

Of course our index.html includes:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

We've tried pretty much everything possible, so I'd be really grateful for anybody pointing us in the right direction...

Thank you in advance,

Luca

Accepted Solutions (1)

Accepted Solutions (1)

lucam_shamat
Participant

Dear collective wisdom,

thanks to the kind help of a SAP HANA distinguished engineer (robin.vanhethof) I was led to look at the problem from a different angle.

If SAP UI5 is perfectly able to automatically deal with Unicode characters and my text data looked perfectly OK in HANA table fields, wasn't possibly the problem the function [ getString() ] I was using to read data from HANA fields? Yep, that was it!

Reading this older conversation, it turns out that getString() should be used for ASCII only fields, for more complex text fields (i. e. non-ASCII) getNString() should be used.

Problem solved!

🙂

0 Kudos

Hi Luca,

Thanks for sharing the information, this really helps. It worked for me 🙂

Answers (1)

Answers (1)

Qualiture
Active Contributor

Hi Luca,

JSON is always encoded as UTF-8 (https://tools.ietf.org/html/rfc7159#section-8.1) so that shouldn’t be the issue.

Also, SAPUI5 is perfectly capable of displaying UTF-8 diacritics (see this small example: https://jsbin.com/tezuhob/edit?html,js,output)

Only two things I can think of right now:

  1. Can you check whether the JSON data stored in your HANA tables has the correct encoding?
  2. Can you check whether the data retrieved from HANA into your SAPUI5 app has the correct encoding?
lucam_shamat
Participant
0 Kudos

Thank you for this important head-up!