public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Patrick Ellis" <Patrick.Ellis@sas.com>
To: <mauve-discuss@sources.redhat.com>
Subject: Question about getEncoding method on different platforms
Date: Wed, 05 Mar 2003 16:11:00 -0000	[thread overview]
Message-ID: <F2E670D5036BE14E89473A3FAEDE6ACE428F9F@merc18.na.sas.com> (raw)


I have testcases that are failing across several platforms because the encoding value that is returned from the different platforms does not match the
8859_1 value that is being expected by the testcase. Example the value of ASCII is returned for Sun and Linux. 

Question: Should the mauve code be changed to reflect the correct values expected for each platform ?

Code:
gnu/testlet/java/io/InputStreamReader/jdk11.java

// Tags: JDK1.1

package gnu.testlet.java.io.InputStreamReader;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;

import java.io.*;

public class jdk11 implements Testlet
{
  public void test (TestHarness harness)
  {
    try
      {
                InputStreamReader isr = new InputStreamReader (new StringBufferInputStream ("zardoz has spoken"));
                harness.check(!isr.ready(), "ready()");   // deprecated post-1.1
                harness.check(isr.getEncoding(), "8859_1", "getEncoding");
                char[] cbuf = new char[10];
                isr.read (cbuf, 0, cbuf.length);
                String tst = new String(cbuf);
                harness.check(tst, "zardoz has", "read(buf[], off, len)");
                harness.check(isr.read(), ' ', "read()");
                isr.close ();
                harness.check(true, "close()");
      }
    catch (IOException e)
      {
                harness.check(false, "IOException unexpected");
      }
  }
}

gnu/testlet/java/io/OutputStreamWriter/jdk11.java

// Tags: JDK1.1

package gnu.testlet.java.io.OutputStreamWriter;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.io.OutputStreamWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class jdk11 implements Testlet
{
  public void test (TestHarness harness)
  {
    try
      {
                String tstr = "ABCDEFGH";
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                OutputStreamWriter osw = new OutputStreamWriter (baos);  //Default encoding
                harness.check(true, "OutputStreamWriter(writer)");
                harness.check(osw.getEncoding(), "8859_1", "getEncoding");
                osw.write(tstr.charAt(0));                                      // 'A'
                harness.check(true,"write(int)");
                osw.write("ABCDE", 1, 3);                                       // 'ABCD'
                harness.check(true,"write(string, off, len)");
                char[] cbuf = new char[8];
                tstr.getChars(4, 8, cbuf, 0);
                osw.write(cbuf, 0, 4);                                          // 'ABCDEFGH'
                harness.check(true,"write(char[], off, len)");
                osw.flush();
                harness.check(true, "flush()");
                harness.check(baos.toString(), tstr, "Wrote all characters okay");
                osw.close ();
                harness.check(true, "close()");
                ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
                OutputStreamWriter osw2 = new OutputStreamWriter(baos2, "8859_3");
                harness.check(osw2.getEncoding(), "8859_3", "OutputStreamWriter(writer, encoding)");

      }
    catch (IOException e)
      {
                harness.check(false, "IOException unexpected");
      }
  }
}



From JavaTM 2 Platform
Std. Ed. v1.4.1
getEncoding
public String <../../java/lang/String.html>  getEncoding()
	Return the name of the character encoding being used by this stream. 
	If the encoding has an historical name then that name is returned; otherwise the encoding's canonical name is returned. 
	If this instance was created with the OutputStreamWriter(OutputStream, String) <../../java/io/OutputStreamWriter.html>  constructor then the returned name, being unique for the encoding, may differ from the name passed to the constructor. This method may return null if the stream has been closed. 
Returns: 
	The historical name of this encoding, or possibly null if the stream has been closed 
See Also: 
	Charset <../../java/nio/charset/Charset.html> 



Pat Ellis
SDE Build and Test Team
Phone:      (919) 531-0355   
R2263     Patrick.Ellis@sas.com
SAS...  The Power to Know

             reply	other threads:[~2003-03-05 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-05 16:11 Patrick Ellis [this message]
2003-03-06  4:36 ` Brian Jones
2003-03-06 14:39 Patrick Ellis
2003-03-06 16:35 Patrick Ellis
2003-03-07  5:01 ` Brian Jones
2003-03-15 15:59   ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F2E670D5036BE14E89473A3FAEDE6ACE428F9F@merc18.na.sas.com \
    --to=patrick.ellis@sas.com \
    --cc=mauve-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).