# httpStringToUtf8() - MappingTable

**URL:** <https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675>\
**Category:** Programming\
**Tags:** library\
**Created:** [July 19, 2025, 11:27am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675 "2025-07-19T11:27:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thorsten\_Bein](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/thorsten_bein/32/2271_2.png) [@Thorsten\_Bein](https://community.br-automation.com/u/Thorsten_Bein)\
**Post date:** [July 19, 2025, 11:27am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/1 "2025-07-19T11:27:03Z")

</div>

Ich kann leider in den Beschreibungen nicht genau rausfinden, wie die MappingTable für AsHttp - httpStringToUtf8() aufgebaut wird.

Ich hatte das mal so probiert:  
VAR CONSTANT  
MappingTable\_DE : WSTRING[255] := “Ä=U+00C4;Ö=U+00D6;Ü=U+00DC;ä=U+00E4;ö=U+00F6;ü=U+00FC;ß=U+00DF;€=U+20AC;”;  
END\_VAR

Aber das scheint nicht zu stimmen…

Hat da vielleicht jemand einen Tipp ?

---

<div class="post-metadata">

**Author:** ![fabian.pries](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@fabian.pries](https://community.br-automation.com/u/fabian.pries)\
**Post date:** [July 21, 2025, 4:55am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/2 "2025-07-21T04:55:29Z")

</div>

Hello @Thorsten_Bein,

I can share this with you..

Providing 0, no mapping is applied and only Unicode characters 0-255 are accepted.  
You have to provide a WSTRING [0..255] or UINT [0..255] via a pointer, where the Unicode positions are entered.

- CodePage : ARRAY[0..255] OF UINT := [16#2000,16#2001,16#2002,16#2003,16#2004,16#2005, ..]

Be aware that after providing the mapping, other characters might not work as expected.

BR Fabian

---

<div class="post-metadata">

**Author:** ![Thorsten\_Bein](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/thorsten_bein/32/2271_2.png) [@Thorsten\_Bein](https://community.br-automation.com/u/Thorsten_Bein)\
**Post date:** [July 30, 2025, 4:41am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/3 "2025-07-30T04:41:27Z")

</div>

Hallo @fabian.pries ,  
thank you for the reply, but i doesn’t understand this.  
I have to exchange the Letters: äöüÄÖÜß€, Space and i don’t know, some others.

---

<div class="post-metadata">

**Author:** ![fabian.pries](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@fabian.pries](https://community.br-automation.com/u/fabian.pries)\
**Post date:** [July 30, 2025, 5:53am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/4 "2025-07-30T05:53:54Z")

</div>

Hello,

for the characters ‘ä ö ü Ä Ö Ü ß’ and SPACE, no mapping table is required.  
These characters are part of the first 255 characters of the unicode table.  
Might put this here as reference: [Unicode/UTF-8-Zeichentabelle](https://www.utf8-zeichentabelle.de/unicode-utf8-table.pl)  
Please note, that the Watch / MonitorWindow / Debugger Watch is not able to display UTF8 characters outside of the first 255 characters.  
You are not allowed to put the characters in your source code since it is not supporting unicode.  
I used the textsystem to present the values to my program.

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/d/d508e3af65dd440a63e0567e010838e0a203de04.png)

For the ‘€’ you need the mapping table since its unicode representation is U+20AC.  
This means the mapping table we have to provide is the “Currency Symbols” starting at U+20A0.  
Extracted from the \*.var file:  
`CodePage : ARRAY[0..255] OF UINT := [16#20A0,16#20A1,16#20A2,16#20A3,16#20A4,16#20A5,16#20A6,16#20A7,16#20A8,16#20A9,16#20AA,16#20AB,16#20AC,16#20AD,16#20AE,16#20AF,240(0)];`

Now the functionblock converts the characters from the source using this mapping leading to the following:

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/e/ef876a9235ef846b27e58f250002b1fdf70c6515.png)

Other characters are no longer supported, since the mapping fails.

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/b/baf737e62cc3ed34d95679619e68cbcaae5f200b.png)

You might want to switch to the httpUTF8ToWString conversion since there is no mapping table required. From the WSTRING it is easy to convert it back to a string using the WSTRING\_TO\_STRING function in ST.

BR Fabian

---

<div class="post-metadata">

**Author:** ![Thorsten\_Bein](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/thorsten_bein/32/2271_2.png) [@Thorsten\_Bein](https://community.br-automation.com/u/Thorsten_Bein)\
**Post date:** [July 30, 2025, 8:29am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/5 "2025-07-30T08:29:19Z")

</div>

Thank you for the new reply @fabian.pries: 😀

I pull the Information with this (Test-) Code:

```auto
PROGRAM _INIT
   RequestHeader.protocol := 'HTTP/1.1';
   RequestHeader.contentType := 'text/html';
   RequestHeader.contentLength := 0;
   RequestHeader.connection := 'Close';
   RequestHeader.keepAlive := 'timeout=5, max=100';
   RequestHeader.userLine[0].name := 'User-agent';
   RequestHeader.userLine[0].value := 'BuR Client';
   RequestHeader.host := 'localhost';

   Client.method := httpMETHOD_GET;
   Client.option := httpOPTION_HTTP_11;
   Client.pHost := ADR('nominatim.openstreetmap.org');
   Client.pUri := ADR('search?q=Mönckebergstraße%2090,8500%20Hamburg&format=json&limit=1');
   Client.pRequestHeader := ADR(RequestHeader);
   Client.hostPort := 443;
   Client.pResponseData := ADR(jsonString);
   Client.responseDataSize := SIZEOF(jsonString);
END_PROGRAM

PROGRAM _CYCLIC
    Client(enable := TRUE); (* Call httpClient() *)  
   
    IF Client.status <> 0 THEN
      Client.send := FALSE;
    END_IF

    IF Client.httpStatus = 200 THEN
         // place_id
        posStart := FIND(IN1 := jsonString, IN2 := '"place_id":') + LEN('"place_id":');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := ',');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.place_id := STRING_TO_UDINT(tempStr);
       
        // licence
        posStart := FIND(IN1 := jsonString, IN2 := '"licence":"') + LEN('"licence":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.licence := MID(restStr, posEnd - 1, 1);
       
        // osm_type
        posStart := FIND(IN1 := jsonString, IN2 := '"osm_type":"') + LEN('"osm_type":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.osm_type := MID(restStr, posEnd - 1, 1);
       
        // osm_id
        posStart := FIND(IN1 := jsonString, IN2 := '"osm_id":') + LEN('"osm_id":');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := ',');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.osm_id := STRING_TO_UDINT(tempStr);
       
        // lat
        posStart := FIND(IN1 := jsonString, IN2 := '"lat":"') + LEN('"lat":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.lat := STRING_TO_REAL(tempStr);
       
        // lon
        posStart := FIND(IN1 := jsonString, IN2 := '"lon":"') + LEN('"lon":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.lon := STRING_TO_REAL(tempStr);
       
        // class
        posStart := FIND(IN1 := jsonString, IN2 := '"class":"') + LEN('"class":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.class := MID(restStr, posEnd - 1, 1);
       
        // type
        posStart := FIND(IN1 := jsonString, IN2 := '"type":"') + LEN('"type":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.type := MID(restStr, posEnd - 1, 1);
       
        // place_rank
        posStart := FIND(IN1 := jsonString, IN2 := '"place_rank":') + LEN('"place_rank":');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := ',');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.place_rank := STRING_TO_INT(tempStr);
       
        // importance
        posStart := FIND(IN1 := jsonString, IN2 := '"importance":') + LEN('"importance":');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := ',');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.importance := STRING_TO_REAL(tempStr);
       
        // addresstype
        posStart := FIND(IN1 := jsonString, IN2 := '"addresstype":"') + LEN('"addresstype":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.addresstype := MID(restStr, posEnd - 1, 1);
       
        // name
        posStart := FIND(IN1 := jsonString, IN2 := '"name":"') + LEN('"name":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.name := MID(restStr, posEnd - 1, 1);
       
        // display_name
        posStart := FIND(IN1 := jsonString, IN2 := '"display_name":"') + LEN('"display_name":"');
        restStr := MID(jsonString, LEN(jsonString), posStart);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        PlaceData.display_name := MID(restStr, posEnd - 1, 1);
       
        // boundingbox[1] bis [4]
        posStart := FIND(IN1 := jsonString, IN2 := '"boundingbox":["') + LEN('"boundingbox":["');
        restStr := MID(jsonString, LEN(jsonString), posStart);
       
        // boundingbox[1]
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.boundingbox[1] := STRING_TO_REAL(tempStr);
       
        // boundingbox[2]
        restStr := MID(restStr, LEN(restStr), posEnd + 2);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.boundingbox[2] := STRING_TO_REAL(tempStr);
       
        // boundingbox[3]
        restStr := MID(restStr, LEN(restStr), posEnd + 2);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.boundingbox[3] := STRING_TO_REAL(tempStr);
       
        // boundingbox[4]
        restStr := MID(restStr, LEN(restStr), posEnd + 2);
        posEnd := FIND(IN1 := restStr, IN2 := '"');
        tempStr := MID(restStr, posEnd - 1, 1);
        PlaceData.boundingbox[4] := STRING_TO_REAL(tempStr);

    ELSE
        // GGF. FEHLERBEHANDLUNG
    END_IF

END_PROGRAM

PROGRAM _EXIT
    (* Release Client instance *)
    Client(enable := 0, send := 0);
END_PROGRAM

```

If there is a Space inside or a Character like ‘ö’ the result will be fail. Alse the Answer from Webserver with Space or äöü etc. will be wrong… And i have to find out a solution…

---

<div class="post-metadata">

**Author:** ![michael\_w](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@michael\_w](https://community.br-automation.com/u/michael_w)\
**Post date:** [July 30, 2025, 2:31pm UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/6 "2025-07-30T14:31:41Z")

</div>

Hi there,

looks like you would need to write a method to replace umlauts (ä, ö, ü, ß) with their respective ascii representation: ä = ae, ö=oe, ü=ue, ß=ss  
`ADR('search?q=Moenckebergstrasse%2090,8500%20Hamburg&format=json&limit=1');`  
will work just fine

* * *

Edit:

```auto
	address_in := 'Mönckebergstraße 90,8500 Hamburg';
	FOR i := 1 TO LEN(address_in) DO
		chr := MID(address_in, 1, i);
		IF chr = 'ä' THEN
			brsstrcat(ADR(tmpStr), ADR('ae'));
		ELSIF chr = 'ö' THEN
			brsstrcat(ADR(tmpStr), ADR('oe'));
		ELSIF chr = 'ü' THEN
			brsstrcat(ADR(tmpStr), ADR('ue'));
		ELSIF chr = 'ß' THEN
			brsstrcat(ADR(tmpStr), ADR('ss'));
		ELSE
			brsstrcat(ADR(tmpStr), ADR(chr));
		END_IF
				
	END_FOR
	FB_EncodeUrl(enable := TRUE, pSrc := ADR(tmpStr), pDest := ADR(address_out), destSize := SIZEOF(address_out));

```

Does the job, FB\_EncodeUrl is a FUB httpEncodeUrl() which converts stuff like the spaces for you.

---

<div class="post-metadata">

**Author:** ![fabian.pries](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@fabian.pries](https://community.br-automation.com/u/fabian.pries)\
**Post date:** [July 31, 2025, 4:38am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/7 "2025-07-31T04:38:32Z")

</div>

I think @michael_w is correct since it issues is not with UTF8 conversion but with the encoding of the URL.

---

<div class="post-metadata">

**Author:** ![Thorsten\_Bein](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/thorsten_bein/32/2271_2.png) [@Thorsten\_Bein](https://community.br-automation.com/u/Thorsten_Bein)\
**Post date:** [August 1, 2025, 7:29am UTC](https://community.br-automation.com/t/httpstringtoutf8-mappingtable/7675/8 "2025-08-01T07:29:13Z")

</div>

Thank you that is a good idea… 🙂
