浏览代码

Fix: IsProbablyUTF8() now works with multi-bytes as last char (#367)

Co-authored-by: Ronny Otto <[email protected]>
Ronny Otto 4 月之前
父节点
当前提交
360e0479f9
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      textstream.mod/textstream.bmx

+ 4 - 1
textstream.mod/textstream.bmx

@@ -512,7 +512,10 @@ Function IsProbablyUTF8:Int(data:Byte Ptr, size:Int)
 	Next
 
 	If count Then
-		Return False
+		' If there was no new-line or non-multi-byte-character at the 
+		' end of the buffer then count will be > 0. So we also have to
+		' check if we can decode the remaining buffer content.
+		If Decode(buf, count) = -1 Then Return False
 	End If
 	
 	Return True