# How to resolve the Chinese garbled text from S7-1500 PLC

**URL:** <https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277>\
**Category:** Ignition\
**Tags:** ignition83, siemens\
**Created:** [July 6, 2026, 10:11am UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277 "2026-07-06T10:11:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poulpe.Yu](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@Poulpe.Yu](https://forum.inductiveautomation.com/u/Poulpe.Yu)\
**Post date:** [July 6, 2026, 10:11am UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/1 "2026-07-06T10:11:52Z")

</div>

Hi all,

We met a issue on reading string tag value from S7-1500 PLC with Ignition S7-1500 driver, the data in the PLC is Chinese character store in DB, and ignition get the string as garbled text. We tried to decode and encode with different character set(UTF8, iso-8859-1, gbk), but failed to get the right Chinese string as recipe name from equipment.

Below is the custom script we using for the string extraction: defined a function to decode the string

```python
def decode_siemens_gbk(raw_string):
	# 1. 安全检查：空值处理 Check if it is null
	if raw_string is None or str(raw_string).strip() == "":
		return ""

	# 2. 如果传入的已经是 unicode 对象 if the raw string is unicode
	if isinstance(raw_string, unicode):
		try:
			# 尝试用 iso-8859-1 还原底层字节流（针对 ׼2_V7 这种真正的单字节乱码）
			# Try using iso-8859-1 to restore the underlying byte stream
			raw_bytes = raw_string.encode('iso-8859-1')
			return raw_bytes.decode('gbk', 'ignore')
		except UnicodeEncodeError:
			# 【触发报错的地方】如果含有 latin-1 无法编码的字符，说明里面已经有真正的中文字符
			# If it contains characters that latin-1 cannot encode, it means there are already real Chinese characters inside
			try:
				# 尝试直接用 gbk 重新解码（以防万一）Try directly decoding with gbk
				return raw_string.encode('utf-8').decode('gbk', 'ignore')
			except Exception:
				# 如果怎么转都错，说明这个字符串在 Ignition 里已经是正确的中文了，直接返回原值
				#If no matter how you convert it, it means the string is already in correct Chinese in Ignition,
				#and it returns the original value directly
				return raw_string

	# 3. 如果传入的是标准 str (字节流) If the input is a standard str (byte stream)
	else:
		try:
			return str(raw_string).decode('gbk', 'ignore')
		except Exception:
			return str(raw_string)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/2/2263bbe8477a5058a2f2526d06fc290b5152a624.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f766034ea84fa1048cfeea16ba870c623f2d2bed.png)

[Chinese garbled text.txt](https://forum.inductiveautomation.com/uploads/short-url/3B97nAU2I5Sc8HSc1UYZd6d6rIW.txt) (1.6 KB)

Do you have any experience on this topic, or any suggestion to help us? Thanks for your support and kindness in advance!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 6, 2026, 3:21pm UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/2 "2026-07-06T15:21:05Z")

</div>

I've done my best to recover the code formatting on your original post; see [this thread](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831) for more instructions on how to do it.

Step 1, most likely, is to drop all this stuff you're trying to do via scripting. Strings Ignition returns to you are natively unicode and you don't have to mess around with encodings in most scenarios.  
Post the **exact** value of what `raw_string` is as soon as you get it - e.g. use `system.util.getLogger("stringDebug").infof("raw string: %s", repr(raw_string))`

Also, this is just a hunch, but be very careful with the output of LLMs/AI with regard to Ignition. LLMs need very diligent prompting because they don't fully understand Ignition's context and will happily provide you lots and lots of code you don't actually need.

---

<div class="post-metadata">

**Author:** ![Poulpe.Yu](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@Poulpe.Yu](https://forum.inductiveautomation.com/u/Poulpe.Yu)\
**Post date:** [July 6, 2026, 3:36pm UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/3 "2026-07-06T15:36:27Z")

</div>

Thanks for your comments and instructions, it's my first time to post topic.

Here is the exact value of the raw\_string from PLC following your suggestion:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/0/907abc55a288fb171d952cd78077674699440891.png)

also from another S7-1500 PLC

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/d/addb67b5da2f9975a8b3fa7f5e5959988490f8e5.png)

The common range of Unicode for Chinese characters should be from \u4e00 to \u9fa5.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d82e6533d6c62beed70404d2e7e2dc7343e69500.png)

after transfer from Unicode to Chinese characters like above, it is a mess.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 6, 2026, 3:55pm UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/4 "2026-07-06T15:55:41Z")

</div>

What driver are you using? There are two possible options for communicating with an S7-1500.

---

<div class="post-metadata">

**Author:** ![Poulpe.Yu](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@Poulpe.Yu](https://forum.inductiveautomation.com/u/Poulpe.Yu)\
**Post date:** [July 7, 2026, 1:19am UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/5 "2026-07-07T01:19:59Z")

</div>

only use the S7-1500 driver as below:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbb29f3a69abf9b0b474c643f970f626d7c5c9a4.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 7, 2026, 1:50am UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/6 "2026-07-07T01:50:28Z")

</div>

You have no chance at reinterpreting the bytes, by the time they've gotten to you they've already been turned from bytes into a string using the platform encoding. It probably should be explicitly UTF-8 instead of whatever the platform encoding happens to be, but that's how it's implemented right now.

You might try setting `-Dfile.encoding=UTF-8` in `ignition.conf` (requires gateway restart) to see if that changes anything for you...

---

<div class="post-metadata">

**Author:** ![Poulpe.Yu](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@Poulpe.Yu](https://forum.inductiveautomation.com/u/Poulpe.Yu)\
**Post date:** [July 8, 2026, 10:54am UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/7 "2026-07-08T10:54:11Z")

</div>

> [@Poulpe.Yu](#):
>
> .Thanks for your comments, I check the ignition.conf on my laptop with Ignition 8.3.1 and have a test to connect to the S7-1515 PLC. Before adding the setting as your mentioned 'wrapper.java.additional.8=-Dfile.encoding=UTF-8', the string captured from PLC to ignition shown as 2.png
> 
> ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/95fec43a1091e9fe0cdefc2c779ec6c5fd26f244.png)

After added the additional setting, he string captured from PLC to ignition shown as 1.png

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/5/f57ce693b08f18d226ad759c12dc7bbb8e944915.png)

It seems our DEV Igniton edge server has already configured the UTF-8 encoding setting.

Beside, the variable address table on the two S7-1500 PLCs are set as shown below, with variable names created in Chinese, we retrieved the variable with address [devicename]DB3,STRING46.25 and [devicename]DB23,STRING94.20, why not using 254 as offset since it would cause all the data retrieved from PLC crashed in Ignition.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/f/9fd760e49f7a53b59602b6c9c43e507f442066d6.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2fd0d1169bf58bba02bb3fc8893d6cfcf07fb222.jpeg)

Thanks for your support!

---

<div class="post-metadata">

**Author:** ![Poulpe.Yu](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@Poulpe.Yu](https://forum.inductiveautomation.com/u/Poulpe.Yu)\
**Post date:** [July 13, 2026, 10:24am UTC](https://forum.inductiveautomation.com/t/how-to-resolve-the-chinese-garbled-text-from-s7-1500-plc/116277/8 "2026-07-13T10:24:02Z")

</div>

Finally, we found the solution:

Using system.opc.readValue to read the string value by Bytes, taking [devicename]DB3,STRING46.25 for example, the string start from Byte offset 46 in DB3, the string length is stored in Byte offset 47 in DB3 and the actual first character should be stored in Byte offset 48 in DB3. After get all the characters in bytes array with the length from Byte offset 47 in DB3, and change them to signed byte (if the bytes large than 256 then subtract 256), then translate them to GBK set with JString function from Java, and we could get the right Chinese string.
