ソースを参照

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
 	Next
 
 
 	If count Then
 	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
 	End If
 	
 	
 	Return True
 	Return True