18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Utils.java - our writeFile encoding fix
We use Russian language in site being tested under Sahi, and
so we detected encoding/decoding mismatch between _readFile and _writeFile.
_writeFile calls Utils.java:writeFile, that calls getBytes with platform default encoding,
cp-1251 for most computers in Russia.
_readFile calls Utils.java:readFile, wich use Utils.java:getString that assume UTF-8 if no
exception raised.
so sahi stores String into File in cp-1251 on Russian computers,
and reads UTF-8. Our fix (may be NOT PERFECT):
public static void writeFile(String str, String filePath, boolean overWrite) {
..................
out.write((str).getBytes("UTF-8"));//GARANT
..................
}
so we detected encoding/decoding mismatch between _readFile and _writeFile.
_writeFile calls Utils.java:writeFile, that calls getBytes with platform default encoding,
cp-1251 for most computers in Russia.
_readFile calls Utils.java:readFile, wich use Utils.java:getString that assume UTF-8 if no
exception raised.
so sahi stores String into File in cp-1251 on Russian computers,
and reads UTF-8. Our fix (may be NOT PERFECT):
public static void writeFile(String str, String filePath, boolean overWrite) {
..................
out.write((str).getBytes("UTF-8"));//GARANT
..................
}
Comments
Your fix looks fine. Thanks for pointing out. We will add an option to specify the encoding.
Regards,
Narayan