succlz123 / DLNA-Dart

A simple DLNA DMC library implemented by Dart.
Other
82 stars 28 forks source link

Content size exceeds specified content length.1091bytes written while expected 1086. #3

Closed idootop closed 4 years ago

idootop commented 4 years ago

Snipaste_2020-06-18_15-12-12 当设置title为中文时会报错:Content size exceeds specified content length. 修复这个问题的方法是,在文件 \lib\src\soap\soap_action.dart 的第45行,把 headers.contentLength = content.length ,修·改为 headers.contentLength = utf8.encode(content).length,因为中文字符在 UTF-8 编码后的长度不等于原字符串长度。(1中文字符=2英文字符)


The error occurs when setting the title to Chinese: Content size exceeds specified content length. The way to fix this problem is to add it to the file \lib\src\soap\soap_action. dart on line 45 and replace headers.contentLength = content.length , amend - to headers. contentLength = utf8.encode(content).length,because the length of Chinese characters after UTF-8 encoding is not equal to the length of the original string. (1 Chinese character = 2 English characters)

idootop commented 4 years ago

非常感谢你的这个项目,它帮了我很大忙,谢谢!


Thank you so much for this project, it has helped me so much, thank you!

succlz123 commented 4 years ago

lol, thank you for your suggestion.