Question Edoeard Kroetkov · Jan 23, 2023

view diacritics in REST service

I have code hier and trying to view diacrit character

Class Test.REST.Services Extends EnsLib.REST.Service
{

Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter";

Parameter EnsServicePrefix = "^TEST";

XData UrlMap
{
<Routes>
<Route Url="/dio/:Resource" Method="GET"     Call="getDio" />
</Routes>
}

Method getDio(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object, pResource As %String) As %Status
{
    
        set status = $$$OK
        do pOutput.SetAttribute("ResponseCode","200")
        set messageBuffer = "{""text"":""Patiënt""}"
        do pOutput.Write(messageBuffer)
        do pOutput.SetAttribute("Charset","UTF-8")
        set status = ##class(%SYSTEM.Status).OK()
         Quit $$$OK
}

}

But as response i get different character

{"text":"Pati�nt:"}

any help will be appreciated

Hierwith my settings i use and trying

Product version: IRIS 2020.1
$ZV: 2020.1.0 build 217 path1

Comments

Manel Trèmols · Jan 25, 2023

Hi Edoeard,

Try adding parameter CHARSET:

/// Main TDF REST service entry point
Class TDF.Main Extends %CSP.REST
{

Parameter CHARSET = "UTF-8";

Regards

Manel

0
Edoeard Kroetkov · Jan 30, 2023

Hi Manel

I tryed this parameter. response is still {"text":"Pati�nt:"}

I did use other Extends than you is It matter? Extends EnsLib.REST.Service

Regards 

Eduard

0
Edoeard Kroetkov · Feb 2, 2023

Hi Manel

I tryed this parameter. response is still {"text":"Pati�nt:"}

I did use other Extends than you is It matter? Extends EnsLib.REST.Service

Regards 

Eduard

0
Gertjan Klein · Feb 2, 2023

I would file this with WRC. The settings documentation suggest that you can specify the in- and output encoding with the Charset (Tekenset) setting. That implies that you should set that to utf-8, but that doesn't actually work. From looking at the source code, it appears that the business service (EnsLib.REST.Service) hardcodes a %GlobalBinaryStream response stream, which will output the bytes as they are.

As a workaround you could convert (encode) the stream to UTF-8 yourself before sending it.

0