Question
· 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
Discussion (4)2
Log in or sign up to continue

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.