to get the item labels I would like the REST API, but I´m not able to display special characters in my web page correctly. Is my suspicion correct that the REST API does not use UTF-8/Unicode for the data transmission?
If yes - do you know what encoding/code page is used and or if this can be configured?
HTTP/1.1 200 OK
Date: Fri, 11 Aug 2017 16:22:15 GMT
Content-Type: application/json
Content-Length: 349
Server: Jetty(9.2.19.v20160908)
{"link":"http://haus:8080/rest/items/ItemTemperaturBastelzimmer","state":"24.1","stateDescription":{"pattern":"%.1f C","readOnly":false,"options":[]},"type":"Number","name":"ItemTemperaturBastelzimmer","label":"G stezimmer","category":"temperatur","tags":[],"groupNames":["GroupPersistrrd4jHour","GroupTemperaturOGAverage","GroupTemperaturZimmer"]}
Finding
As an “application/json” response I expect UTF-8 encoding; which it actually is - but the character \u00E4 (ä) is sent to the client as \uFFFD (label=G\uFFFDstezimmer). Thus jetty used a replacement character here … basic UI displays the item correctly:
Thank you - I´m happy that this can be reproduced. Do you know if I should open an issue for this? If so do you know where that belongs to; is https://github.com/openhab/openhab-distro/issues the right place?
// Get the item label from the list of all items received from
// openHAB; this is necessary with OH 2.2 due to encoding problems
// if we query the item directly.
//
// Required API:
// - http://code.google.com/p/jsonpath/
function GetItemLabelFromJSON(json, itemName) {
var path = "$.[?(@.name==\"" + itemName + "\")].label";
return jsonPath(json, path);
}
function GetAllItemInformationJSON() {
var allItemsUrl = baseURL.concat("rest/items?recursive=false");
return GetData(allItemsUrl);
}