18 January 2026:


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.

SAHI and UTF-16

pinepine Members
edited May 2013 in Sahi - Open Source
Hello All,

My web application generates UTF-16 web pages and it looks like this situation is not recognized by SAHI correctly. With embedded Sahi code on top contains Sahi code in UTF-8, then comes two bytes that identifies UTF-16, then comes all page data starting with <html>. Internet explorer gets confused about that and displays page as UTF-8. Is it possible to add/switch on UTF-16 support?

Answers

  • pinepine Members
    anyone?
  • Hi Pine,
    Can you please attach the URL of the webpage you are referring to?
  • pinepine Members
    It is on internal site. Any page in UTF-16 is ok.
  • pinepine Members
    Resolved the problem myself. Root cause was that our Web server gives iso8859-1 charset in HTTP header for pages that contain UTF-16 in HTML. So, one-line fix for net.sf.sahi.response.HttpModifiedResponse2 first constructor is to check if first two bytes of HTTP data are -1 and -2 (UTF-16 identification codes)

    if (responseCode < 300 || responseCode >= 400) { // Response code other than 3xx
    boolean html = isHTML();
    boolean js = isJs();
    if (html || js){
    charset(); // set it
    final byte[] data = data();

    INSERT HERE ===> if ((data[0] == -1) && (data[1] == -2)) charset="UTF-16";

    if (data == null) {
    dataString = "";
    } else {
Sign In or Register to comment.