Code: Select all
"Main"
$text = "纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)";
writefile("<xydata>\Log\XYplorer.log", $text.<crlf>, 'a', 't');
Code: Select all
纽约灾星 The Jinx: The Life and Deaths of Robert Durst (201
Code: Select all
"Main"
$text = "纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)";
writefile("<xydata>\Log\XYplorer.log", $text.<crlf>, 'a', 't');
Code: Select all
纽约灾星 The Jinx: The Life and Deaths of Robert Durst (201
Code: Select all
echo isunicode("纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)");
Code: Select all
echo isunicode("纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)", 1);
admin wrote:Interesting!
1Code: Select all
echo isunicode("纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)");
0Code: Select all
echo isunicode("纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)", 1);
Thanks for the fix. However, this update writes file as utf-16le which is the same as `tu` mode. It should write file as utf-8 Is there anyway to write file as utf-8?v17.30.0102 - 2016-11-09 20:53
! SC writefile: On DBCS locales (using double-byte character sets: Chinese,
Japanese, Korean) text with Unicode characters would be cropped at the end
when you passed 't' as mode parameter. Fixed.
admin wrote:SC writefile does not support utf-8 conversion. You can use utf8encode() on the string to convert it before passing it to writefile.
Code: Select all
$text = "纽约灾星 The Jinx: The Life and Deaths of Robert Durst (2015)";
writefile("<xydata>\Log\XYplorer.log", utf8encode($text.<crlf>), 'a', 't');
Code: Select all
?o??o|?????? The Jinx: The Life and Deaths of Robert Durst (2015)
Code: Select all
00000000: E7 BA BD E7 BA A6 E7 81 BE E6 98 9F 20 54 68 65 ; 纽约ç¾æ The
00000010: 20 4A 69 6E 78 3A 20 54 68 65 20 4C 69 66 65 20 ; Jinx: The Life
00000020: 61 6E 64 20 44 65 61 74 68 73 20 6F 66 20 52 6F ; and Deaths of Ro
00000030: 62 65 72 74 20 44 75 72 73 74 20 28 32 30 31 35 ; bert Durst (2015
00000040: 29 0D 0A ; )..
This is the correct raw view for the file. However, writefile() converts those wide chars into ?. Therefore, the result file isadmin wrote:This should be the Raw View of the created file:Code: Select all
00000000: E7 BA BD E7 BA A6 E7 81 BE E6 98 9F 20 54 68 65 ; 纽约ç¾æ The 00000010: 20 4A 69 6E 78 3A 20 54 68 65 20 4C 69 66 65 20 ; Jinx: The Life 00000020: 61 6E 64 20 44 65 61 74 68 73 20 6F 66 20 52 6F ; and Deaths of Ro 00000030: 62 65 72 74 20 44 75 72 73 74 20 28 32 30 31 35 ; bert Durst (2015 00000040: 29 0D 0A ; )..
Code: Select all
00000000: 3F 6F 3F 3F 6F 7C 3F 3F 3F 3F 3F 3F 20 54 68 65 ; ?o??o|?????? The
00000010: 20 4A 69 6E 78 3A 20 54 68 65 20 4C 69 66 65 20 ; Jinx: The Life
00000020: 61 6E 64 20 44 65 61 74 68 73 20 6F 66 20 52 6F ; and Deaths of Ro
00000030: 62 65 72 74 20 44 75 72 73 74 20 28 32 30 31 35 ; bert Durst (2015
00000040: 29 0D 0A E7 BA BD E7 BA A6 E7 81 BE E6 98 9F 20 ; )
Can you add a [flags] parameter to let it write a BOM for UTF-8? UTF-16 LE is written with a BOM by default.v17.30.0108 - 2016-11-10 19:07
+ SC writefile enhanced. Added new mode "utf8".
Syntax: writefile(filename, data, [on_exist], [mode])
mode:
utf8: Converts data to UTF-8 before writing it to file. A UTF-8 BOM is
not added.