Browse Source

[lua] fix some utf8 file operation issues

Justin Donaldson 7 years ago
parent
commit
f5decc036f
2 changed files with 8 additions and 1 deletions
  1. 1 1
      std/lua/_std/sys/io/File.hx
  2. 7 0
      std/lua/_std/sys/io/FileOutput.hx

+ 1 - 1
std/lua/_std/sys/io/File.hx

@@ -80,7 +80,7 @@ class File {
 	}
 
 	public static function saveContent( path : String, content : String ) : Void {
-		var f = write(path, false);
+		var f = write(path, true);
 		f.writeString(content);
 		f.close();
 	}

+ 7 - 0
std/lua/_std/sys/io/FileOutput.hx

@@ -22,6 +22,7 @@
 package sys.io;
 
 import lua.FileHandle;
+import haxe.io.Bytes;
 
 class FileOutput extends haxe.io.Output {
 	var f:FileHandle;
@@ -48,6 +49,12 @@ class FileOutput extends haxe.io.Output {
 		f.write(String.fromCharCode(c));
 	}
 
+	override inline public function writeBytes( s : Bytes, pos : Int, len : Int) : Int  {
+		f.write(s.getString(pos, len));
+		return s.length;
+	}
+
+
 	override public function close() {
 		f.close();
 	}