Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1062] Ti.Filesystem.getFile(file).read() returns garbled multibyte string

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNeeds more info
Resolution Date2016-01-07T05:31:47.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelswindows, windows_phone
ReporterToshiro Yagi
AssigneeSharif AbuDarda
Created2015-12-17T08:56:28.000+0000
Updated2016-04-29T17:00:33.000+0000

Description

Reading plain text written in Japanese returns garbled characters.
var filePath = Ti.Filesystem.applicationDataDirectory + "test.txt";
var file = Ti.Filesystem.getFile(filePath);
file.write("日本語 : Japanese");
alert(file.read());

Attachments

FileDateSize
screenshot.png2015-12-17T08:41:30.000+000095216

Comments

  1. Sharif AbuDarda 2015-12-22

    Hello, Try writing the code as
       var log = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'test.txt');
       
           log.write('"日本語 : Japanese"');  
           
           alert(log.read().text);
       
    Hope this helps, Thanks.
  2. Toshiro Yagi 2015-12-22

    Thank you, but it didn't solve the problem(same result).
  3. Sharif AbuDarda 2015-12-23

    Hello, Try the below code
       var log = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'test.txt');
       log.write('日本語 : Japanese');  
       alert(log.read().txt);
       
    Or you can first define a variable like "var str1 = '日本語 : Japanese';" and to call the variable as "log.write(str1)"; Use double " or both if necessary. Reply with your findings. Thanks.
  4. Toshiro Yagi 2016-01-08

    Tried calling variable, single and double quotes, with no result.
  5. Toshiro Yagi 2016-01-08

    Since JavaScript code is right and works on other platforms, please don't mark this issue as resolved as long as returning garbled data is not an acceptable behavior. Thanks.
  6. Kota Iguchi 2016-01-29

  7. Toshiro Yagi 2016-04-29

    Thanks!

JSON Source