character encoding

Discussion in 'Java' started by raavi, Feb 16, 2006.

  1. raavi

    raavi Guest

    Hi all
    I am now involved in a telnet application.the problem i am facing is
    that there are some missing characters .i am using NVTInputStream class
    for character encoding.if any one has any idea please do tell me.Thanks
    in advance
    Regards ,
    Anu
     
    raavi, Feb 16, 2006
    #1
    1. Advertising

  2. raavi

    IchBin Guest

    raavi wrote:
    > Hi all
    > I am now involved in a telnet application.the problem i am facing is
    > that there are some missing characters .i am using NVTInputStream class
    > for character encoding.if any one has any idea please do tell me.Thanks
    > in advance
    > Regards ,
    > Anu
    >

    More specific question with code sample involved will help problem
    determination.

    --

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Feb 16, 2006
    #2
    1. Advertising

  3. raavi

    raavi Guest

    Hi
    the NVTInputStreamReader class i am using is as follows.
    public class NVTInputStream extends FilterInputStream
    {
    byte IAC = (byte)0xff;
    byte DO = (byte)0xfd;
    byte WILL = (byte)0xfb;
    int WONT = 252;
    int DONT = 254;
    OutputStream out;
    int BUFFER_SIZE = 1024;
    byte lineBuffer[] = new byte[BUFFER_SIZE];
    int numBytes = 0;

    public NVTInputStream(InputStream inStream, OutputStream outStream)
    {
    super(inStream);
    out = outStream;
    }

    /**
    * Following function takes each character from the socket
    inputstream
    * It returns each character as integer
    */
    public int read() throws IOException {
    boolean recIAC;
    int i;
    do {
    recIAC = false;
    i = in.read();
    if (i==-1) return i;
    byte b = (byte)i;
    if (b==IAC) {
    recIAC = true;
    int cmd = in.read();
    if (cmd==-1) return cmd;
    byte b2 = (byte)cmd;
    if (b2==IAC) return 255;
    else if (b2==DO) {
    int opt = in.read();
    if(opt==-1) return opt;
    out.write(255);
    out.write(WONT);
    out.write(opt);
    out.flush();
    }
    else if (b2==WILL) {
    int opt = in.read();
    if(opt==-1) return opt;
    out.write(255);
    out.write(WONT);
    out.write(opt);
    out.flush();
    }
    }
    } while (recIAC);
    return i;
    }

    }
    i am using this class to get the stream .i am
    taking the integer conversion of stream and the cnverting to characters
    ..but some characters are seen missing.so if possible suggest me some
    new character encoding measures.Thanks in advance
     
    raavi, Feb 16, 2006
    #3
  4. raavi

    Chris Uppal Guest

    raavi wrote:

    > public class NVTInputStream extends FilterInputStream

    [...]
    > public int read() throws IOException {

    [...]
    > i am using this class to get the stream .i am
    > taking the integer conversion of stream and the cnverting to characters
    > .but some characters are seen missing.


    If the code you posted was a complete class, then one way that things might be
    going wrong is that if the code that uses the stream calls one of the other
    flavours of the read() method then your filtering code will not be invoked.

    -- chris
     
    Chris Uppal, Feb 16, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harley

    foreign character encoding

    Harley, Jul 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,009
    Harley
    Jul 26, 2003
  2. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,931
    Jon Skeet [C# MVP]
    Jun 9, 2004
  3. Replies:
    1
    Views:
    23,444
    Real Gagnon
    Oct 8, 2004
  4. raavi
    Replies:
    2
    Views:
    917
    raavi
    Mar 2, 2006
  5. Replies:
    2
    Views:
    389
Loading...

Share This Page