New Charset Encoder/Decoder for Microsoft telnet

Hello,
I have a problem for writing a server which is accessible by microsoft windows telnet.
I have managed to find out these relationships:
          switch ((int) c) {
               case -27: c = '�'; break;
               case -28: c = '�'; break;
               case -102: c = '�'; break;
               case -103: c = '�'; break;
               case -108: c = '�'; break;
               case -114: c = '�'; break;
               case -124: c = '�'; break;
               case -127: c = '�'; break;
So how could i write an encoder/decoder which could map these charcters specially and others as norma ISO-8859-1.
I switched them after encoding/decoding but then i got problem, that
i got two characters(in telnet window). First was some wierd symbol and second the right character.
Any help lplease?

Okay, got working the charset include and everything is okay.
Now i need to look after charcodes below 0. I though that it would be useful to create new charset for this purpose which adds little extra functionality to IBM850. When running this code it says that IBM850 charset not found when initilizating X-MICRO charset. But it is accessible in main program. Any ideas what is wrong?... Please help me, this damn internationallization has driven me mad.
package ee.feelfree.charset;
import java.nio.charset.Charset;
import java.nio.charset.spi.CharsetProvider;
import java.util.HashSet;
import java.util.Iterator;
public class MicrosoftCharsetProvider extends CharsetProvider {
     private static final String CHARSET_NAME = "X-MICRO";
     private Charset micro = null;
     public MicrosoftCharsetProvider()
     this.micro = new MicrosoftCharset (CHARSET_NAME, new String [0]);
     public Iterator charsets() {
          HashSet set = new HashSet (1);
          set.add (micro);
          return (set.iterator());
     public Charset charsetForName (String charsetName) {
          if (charsetName.equalsIgnoreCase (CHARSET_NAME)) {
               return (micro);
               return (null);
package ee.feelfree.charset;
import java.nio.CharBuffer;
import java.nio.charset.*;
import java.nio.ByteBuffer;
public class MicrosoftCharset extends Charset {
     private static final String BASE_CHARSET_NAME = "IBM850";
     Charset baseCharset;
     protected MicrosoftCharset(String canonical,String [] aliases) {
          super (canonical, aliases);
          baseCharset = Charset.forName(BASE_CHARSET_NAME);
     public CharsetEncoder newEncoder() {
          return new MicrosoftEncoder(this,baseCharset.newEncoder());
     public CharsetDecoder newDecoder() {
          return new MicrosoftDecoder(this,baseCharset.newDecoder());
     public boolean contains (Charset cs) {
          return false;
     private class MicrosoftEncoder extends CharsetEncoder {
          private CharsetEncoder baseEncoder;
          MicrosoftEncoder(Charset cs,CharsetEncoder baseEncoder) {
               super(cs, baseEncoder.averageBytesPerChar(),
                         baseEncoder.maxBytesPerChar());
               this.baseEncoder = baseEncoder;
          protected CoderResult encodeLoop (CharBuffer cb, ByteBuffer bb)
               CharBuffer tmpcb = CharBuffer.allocate (cb.remaining());
               while (cb.hasRemaining()) {
               tmpcb.put (cb.get());
               tmpcb.rewind();
               baseEncoder.reset();
               CoderResult cr = baseEncoder.encode (tmpcb, bb, true);
               cb.position (cb.position() - tmpcb.remaining());
               return (cr);
     private class MicrosoftDecoder extends CharsetDecoder
     private CharsetDecoder baseDecoder;
     private boolean microClient = false;
          MicrosoftDecoder (Charset cs, CharsetDecoder baseDecoder)
               super (cs, baseDecoder.averageCharsPerByte(),
               baseDecoder.maxCharsPerByte());
               this.baseDecoder = baseDecoder;
          protected CoderResult decodeLoop (ByteBuffer bb, CharBuffer cb)
               baseDecoder.reset();
               CoderResult result = baseDecoder.decode (bb, cb, true);
               myDecode (cb);
               return (result);
          public boolean getClient() {
               return microClient;
          private void myDecode(CharBuffer cb) {
               microClient = false;
               for (int pos = cb.position(); pos < cb.limit(); pos++) {
                    int c = (int) cb.get (pos);
                    if (c<0) microClient=true;
}

Similar Messages

  • Can someone tell me about encode,decode for http url parameters

    All,I got a problem that i want to redirect a url takes some parameters by GET type.if one parameter with url is a passwd field ,i thought it must be encode.And decode by recive-page.what class default in java can i use to encode the field and decode it.Or any solution better.please tell me.thank~

    NEVER send a password using a GET - always use a POST. Otherwise, the password will be transmitted in plain text in the GET header.
    URLEncode / decode is used to convert non-allowed ASCII characters (i.e. characters not allowed by the specification in parameter names or values) into a hex representation so they can be properly parsed. The receiving end uses URLDecode so the receiver obtains the exact parameters that were sent.
    For example, if you wanted to pass a parameter called 'name' a value of 'big joe', you could try doing:
    GET Servlets/myServlet?name=big joe
    but this would not be valid, because spaces are not allowed in URL parameter lists (although Microsoft IE and IIS incorrectly allow this).
    Instead, you should send:
    GET Servlets/myServlet?name=big%20joe
    The ascii value of a space is 32, which is hex 20 (0x20), thus the %20.
    Hope that helps!
    - K

  • Quad Encoder Decode for FPGA

    Quad Encoders are commonly used position feedback devices.  I'm exploring the possibility of using a Scancon 2RMHF with cRIO or sbRIO, it's has 500cpt on AB, plus a once per rev pulse.  A quick search on the internet shows there are many dedicated ICs that will convert the Quad AB signals to position, e.g. HTLC-2032 or LS7366.
    My question is, if I use cRIO or sbRIO, do NI have ready-to-use FPGA code that will perform the same function as the ICs ?   I have searched ni.com for "quad encoder" but with limited results.

    You can use the onboard FPGA on CompactRIO or Single-Board RIO with Digital I/O to read from most quadrature encoders directly.  You just need to ensure you use a DIO module that is fast enough to capture all the digital edges of your quad encoder signal at the fastest rotational rate of your encoder (500cpt * the number of turns/sec).  The faster the I/O module you use relative to the speed of the encoder pulses, the better accuracy you will acheive with the FPGA.
    To get started with the FPGA programming you can reference this developer zone article on Quadrature Encoders, which I found referenced from ni.com/ipnet, your one-stop-shop for finding NI FPGA example programs and reference IP.
    I also like to use the handy functions generated by the FPGA wizard manually in my FPGA applications.  You can find the Quad Encoder functions here on your hard drive after you install LabVIEW FPGA:   C:\Program Files\National Instruments\LabVIEW 2009\FPGAWizard\PlugIns\Function\niRIOQuadCtr\Templates\Fpga
    I would recommend copying any VIs you use from this folder into your own "user VIs" folder so you have the ability to update or modify them if you see fit without affecting the functionality of the original FPGA Wizard.
    Hope this helps,
    Spex
    National Instruments
    To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be...

  • Basic Text Encoder/Decoder help

    Hi. I'm trying to make a Encoder/Decoder for a program to make the gamesaves safer, since they are in a .dat file and can be changed in Notepad. I was wondering if the Text can be Encoded (like a=l, b=m, ect) and decoded using a simple code before the UTF is written.

    Ok, now I have a bit of a problem. I am trying to at least read the hash using readByte(), but the hashes are different. This is the code I'm using:
    public void Load() //Load Script
         { try
                   md5Actor_2 = MessageDigest.getInstance("MD5","SUN");
                   md5Actor_1 = MessageDigest.getInstance("MD5","SUN");
                   md5_1 = md5Actor_1.digest(hash_1.getBytes());
                   md5_2 = md5Actor_2.digest(hash_2.getBytes());
              catch (NoSuchProviderException e1)
                   System.out.println(e1);
              catch (NoSuchAlgorithmException e2)
                   System.out.println(e2);
              //catch (UnsupportedEncodingException e3)
              //     System.out.println(e3);
              load = new FileDialog(dialog, "Load Game v1.1", FileDialog.LOAD);
              load.show();
              file_name = load.getFile();
              f = new File(file_name);
              long modified = f.lastModified();
              if(debug)
                   System.out.println("Last modified:");
                   System.out.println(modified);
              if (f != null)
              { if (file_name != null)
                   { try
                             FileInputStream fis = new FileInputStream(file_name);
                             DataInputStream dis = new DataInputStream(fis);
                             level = dis.readUTF(); //level
                             cur_HP = dis.readUTF(); //cur_HP
                             max_HP = dis.readUTF(); //max_HP
                             atk_str = dis.readUTF(); //atk_str
                             def_str = dis.readUTF(); //def_str
                             cur_exp = dis.readUTF(); //cur_exp
                             exp_ned = dis.readUTF(); //exp_ned
                             loc_x = dis.readUTF(); //loc_x
                             loc_y = dis.readUTF(); //loc_y
                             temp_md5_1[1] = dis.readByte();
                             temp_md5_2[1] = dis.readByte();
                             System.out.println(md5_1+"     "+temp_md5_1);
                             System.out.println(md5_2+"     "+temp_md5_2);
                             if (temp_md5_2 != md5_2)
                                  System.out.println("File Cannot be Loaded. Please Create a new GameSave");
                                  success = false;
                             else
                                  System.out.println("File Loaded Sucessfully: " + file_name);
                                  success = true;
                             if(success)
                             { if (temp_md5_1 != md5_1)
                                       System.out.println("The GameSave is out of date. Saving the game will update "+file_name+"'s GameSave Version");
                             fis.close();
                        catch (Exception e)
                             System.out.println("There was an Error Loading the File: " + file_name);
                             System.out.println(e);
                   if (success)
                        stats_txf.setText("Lvl: "+level+" Health: "+ cur_HP +"/"+ max_HP+"   Exp: "+cur_exp+"/"+exp_ned);
                        loaded = true;
                        setTitle(title+": "+ file_name);
         }Now, I may be reading the file wrong. I know the hash has a length of 16, but if I try to read 16 bytes, I get an EOFException. And, if it's possible, I would like to know how to read an Byte[ ], and not just a Byte.

  • Looking for performance boost to java.nio.charset.encode(String) method

    hi ,
    i have run jprofiler on my application and so that this method takes 4% of the overall CPU time (!) .
    is there any other , faster way to do this encoding ?
    thanks!

    yjavaman wrote:
    i susspect that in my application (multi threaded ) , it is actually a larger bottle neck than i think right now.
    i ask about maybe the caching of the encoder , decoder , maybe i can save this time by doing other stuff .Not sure if you are already buffereing, but from javadoc:
    java.io.OutputStreamWriter
    Each invocation of a write() method causes the encoding converter to be invoked on the given character(s). The resulting bytes are accumulated in a buffer before being written to the underlying output stream. The size of this buffer may be specified, but by default it is large enough for most purposes. Note that the characters passed to the write() methods are not buffered.
    For top efficiency, consider wrapping an OutputStreamWriter within a BufferedWriter so as to avoid frequent converter invocations. For example:
    Writer out = new BufferedWriter(new OutputStreamWriter(System.out));
    Just something simple to use.

  • We have an issue when we send a film to the media encoder it crashes about half of the time for no particular reason. Anyone else got that too with Premiere Pro CC and the new Media encoder? Thanks! bedrijfsfilm Companyfilms

    We have an issue when we send a film to the media encoder it crashes about half of the time for no particular reason. Anyone else got that too with Premiere Pro CC and the new Media encoder?

    We have an issue when we send a film to the media encoder it crashes about half of the time for no particular reason
    Anyone else got that too with Premiere Pro CC and the new Media encoder?
    Lack of detailed info makes your question impossible for anyone to answer you!
    eg. ...."Doctor it hurts...anyone else got something that hurts?" 

  • I am looking for Microsoft office for my new macbook pro

    I am looking for Microsoft Office for my new Macbook Pro.

    MS isn't selling a version through the MAS. There are rumors that they are developing a version for next year.

  • My new iMac 10.7.3 rejects the installation disc for Microsoft Office 2011. What shall I do?

    My new iMac 10.7.3 rejects the installation disc for Microsoft Office 2011. What shall I do?

    A little more description would help. What exactly do you mean by Rejects the disc? Does the DVD drive eject the disc shortly after inserting it?
    Does the Office installer say something, like can't install on this Mac?
    If the Office disc is ejected shortly after insertion try cleaning the disc. Try another DVD disc of any type to see if it is the Office DVD or if the drive ejects all discs.
    If it ejects all DVD or CD discs then the drive is bad and you ned to Return your new Mac fro a Full Refund and then buy another NEW unit.

  • Hey, I'm new to mac, is there a software in App store like Endnote X5 for Microsoft word?

    Hey, I'm new to mac, is there a software in App store like Endnote X5 for Microsoft word?

    Glad you got it working OK. Because you are new to OS X and have recently made the switch I would STRONGLY recommend you bookmark and frequently visit these site:
    Switch 101
    Mac 101
    Find Out How Video tutorials
    Also if you need help with MS Office Microsoft host's a forums specifically for the Mac version. You can find it at:
    Office for Mac Product Forums.

  • Yet another Base64 encoder / decoder

    Hi, I would like introduce a different Base64 encoding scheme which yields slightly more compact results when encoding international characters.
            This is an implementation of BASE64UTF9 encoder and decoder.
            Common practice converts Java strings to UTF8 before Base64 encoding.
            UTF8 is not so space efficient in representing non-ASCII characters.
            While UTF9 is impractical as raw data in most 8 bit machines, it fits
            well within Base64 streams since 3 symbols can represent 2 UTF9 nonets.
            In this implementation, a modified UTF9 (flipped bit 9) is chosen to
            ensure nonet '0x000' never appear but maybe be inserted if needed.
            This implementation is also coded in such a way that it is possible to
            use Base100 encoding. When run from command line, it will perform a
            test with random strings and display encoding compactness compared to
            to other existing schemes.
    public class B64utf9 {
            private static final String look =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
    //"\u0010\u0011\u0012\u0013\u0014!\"#$%&'()*+,-./ 0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
            private static final int BASE = look.length();
            private static final int SYMB = (int)java.lang.Math.pow(BASE, 1.5) / 2;
            public static String decode(String str) {
                    long j = 1, k = 0, q = 0;
                    StringBuffer buf = new StringBuffer();
                    for(int p = 0; p < str.length(); p++) {
                            k += look.indexOf(str.charAt(p)) * j;
                            for(j *= BASE; j >= SYMB * 2; j /= SYMB * 2) {
                                    q = q * SYMB + k % SYMB;
                                    if(k % (SYMB * 2) >= SYMB) {
                                            buf.append((char)q);
                                            q = 0;
                                    k /= SYMB * 2;
                    return buf.toString();
            public static String encode(String str) {
                    long j = 1, k = 0;
                    StringBuffer buf = new StringBuffer();
                    for(int p = 0; p < str.length(); p++) {
                            long r, q = str.charAt(p);
                            for(r = 1; r * SYMB <= q; r *= SYMB);
                            for(; r > 0; r /= SYMB) {
                                    k += ((q / r) % SYMB + (r > 1 ? 0 : SYMB)) * j;
                                    for(j *= SYMB * 2; j >= BASE; j /= BASE) {
                                            buf.append(look.charAt((int)k % BASE));
                                            k /= BASE;
                    if(j > 1) buf.append(look.charAt((int)k));
                    return buf.toString();
            public static void main(String arg[]) throws Exception {
                    java.util.Random rnd = new java.util.Random();
                    for(double q = 1; q < 9; q++) {
                            int x = 0, y = 0, z = 0;
                            int r = (int)java.lang.Math.pow(Character.MAX_VALUE, 1 / q);
                            for(int p = 0; p < 999; p++) {
                                    StringBuffer buf = new StringBuffer();
                                    while(rnd.nextInt(99) > 0) {
                                            char k = 1;
    // varying ASCII density
                                            for(int j = 0; j < q; j++)
                                                    k *= rnd.nextInt(r);
                                            buf.append(k);
                                    String str = buf.toString();
    // regression
                                    if(!decode(encode(str)).equals(str))
                                            System.out.println(str);
    // count encoded length
                                    x += encode(str).length();
                                    y += new sun.misc.BASE64Encoder().encode(str.getBytes("utf8")).length();
                                    z += new sun.misc.BASE64Encoder().encode(str.getBytes("gb18030")).length();
                            System.out.println(x +","+ y +","+ z);
    }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Good idea! Sometimes it depends on what you want to encode too, however.
    I suppose there is a case where general purpose compression does not work very well - random generated data.
    Here's how I tested it:
    class Count {
            private static String enc(String src, String set) throws Exception {
                    return new String(src.getBytes(set), "iso-8859-1");
            private static byte[] dec(byte[] src, String set) throws Exception {
                    return new String(src, set).getBytes("iso-8859-1");
            public static void main(String[] arg) throws Exception {
                    java.util.Random rnd = new java.util.Random();
                    int x = 0, y = 0;
                    for(int k = 0; k < 99; k++) {
                            byte[] raw = new byte[rnd.nextInt(99)];
                            for(int z = 0; z < raw.length; z++)
                                    raw[z] = (byte)(rnd.nextInt(256));
                            String str = new String(raw, "utf16");
                            byte[] b6u = str.getBytes("x-base64utf9");
                            byte[] gz2 = enc(enc(str, "utf8"), "x-gzip").getBytes("x-base64");
                            x += b6u.length;
                            y += gz2.length;
                            if(!str.equals(new String(b6u, "x-base64utf9")))
                                    System.out.println(str);
                            if(!str.equals(new String(dec(dec(gz2, "x-base64"), "x-gzip"), "utf8")))
                                    System.out.println(str);
                    System.out.println(x +","+ y);
    }The above code does not include my my encoders, I put my encoders code as nio.charset package and can be downloaded from [SF.|http://sourceforge.net/project/showfiles.php?group_id=248737]
    PS: sorry about the confusion, please allow me to clarify that the UTF9 encoder is not interchangeable with existing Base64 encoders. There is a compatible (hopefully) encoder in my package, however.

  • XML data - charset encoding problem

    Hello all,
      I am facing an issue on charset encoding. My requirement is to send an XML and read the the output XML to display the output. The output XML is encoded in "ISO-8859-1" and we are retrieving/reading it in "UTF-8". But some special characteres in the output XML are appearing as it is.
      Could some one let me know on how to obtain the desired characters.
    Code snippet while reading the XML:
    BufferedReader inStream = null;
    BufferedWriter outStream = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream(),"UTF-8"));
    inStream =
         new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
    Thanks & regards,
    Sharath

    Hi Sharath,
    To read the XML file use the following. Don’t mention the character set during reading it.I hope it will help you.
    XML file(emp.xml)
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Emp>
    <EmpDetails>
           <firstname>Sarbari</firstname>
           <lastname>Saha</lastname>
      </EmpDetails>
      <EmpDetails>
           <firstname>Tumpa</firstname>
           <lastname>Hazra</lastname>
      </EmpDetails>
    </Emp>
    Java File
    import java.io.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import org.w3c.dom.NamedNodeMap;
    class ReadXML
         public static void main(String args[])
              try
                   String fileName="emp.xml";
                   DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                   Document doc = docBuilder.parse (fileName);
                   NodeList nodeList = doc.getChildNodes();
                   int nodeSize = nodeList.getLength();
                   for (int i=0;i<nodeSize;i++)
                        Node node = nodeList.item(i);
                        Element elm = (Element) node;
                        NodeList EmpDetailsList=elm.getElementsByTagName("EmpDetails");
                        int stNodeSize = EmpDetailsList.getLength();
                        System.out.println("NodeSize =  "+stNodeSize );
                        for(int j=0;j<stNodeSize;j++)
                                  Node nodeEmpdtl = EmpDetailsList.item(j);
                                  Element elmDetails = (Element) nodeEmpdtl;
                                  NodeList firstnameList=elmDetails.getElementsByTagName("firstname");
                                  NodeList lastnameList=elmDetails.getElementsByTagName("lastname");
                                  Node fnameNode=firstnameList.item(0);
                                  System.out.print("Node : " + fnameNode.getNodeName());
                                  System.out.println ("  Value : "+((Element)fnameNode).getChildNodes().item(0).getNodeValue());
                                  int lastnameNodeSize = lastnameList.getLength();
                                  Node lnameNode=lastnameList.item(0);
                                  System.out.print("Node : " + lnameNode.getNodeName());
                                  System.out.println("  Value : "+((Element)lnameNode).getChildNodes().item(0).getNodeValue());
              catch(ParserConfigurationException pce)
                   System.out.println("Inside ParserConfigurationException Exception");
              catch(SAXException se)
                   System.out.println("Inside SAXException Exception");
              catch(IOException ioe)
                   System.out.println("Inside IOException Exception");
    Regards,
    Mithu

  • How to set the charset encoding dynamically in JSP

    Is there any way to set the charset encoding dynamically in a JSP
    page?
    we are using weblogic 6.1 on HP unix.
    is there some way we can set the charset dynamically in the page directive
    <%@ page contentType="text/html;charset=Shift_JIS" %>
    and in MAET tag
    <meta http-equiv="Content-Type" content="text/html" charset="Shift_JIS">
    Saurabh Agarwal

    Dear Saurabh,
    I guess it is possible. Here is an example I have made some time ago :
    In my html page :
    <form name="form1" METHOD=POST Action=Lang ENCTYPE="application/x-www-form-urlencoded" >
    <p>
    <select name="code" size="1">
    <option value="big5">Chinese</option>
    <option value="ISO-2022-KR">Korean</option>
    <option value="x-euc-jp">Japanese</option>
    <option value="ISO-8859-1">Spanish</option>
    <option value="ISO-8859-5">Russian</option>
    <option value="ISO-8859-7">Greek</option>
    <option value="ISO-8859-6">Arabic</option>
    <option value="ISO-8859-9">French</option>
    <option value="ISO-8559-1">German</option>
    <option value="ISO-8859-4">Swedish</option>
    <option value="ISO-8859-8">Hebrew</option>
    <option value="ISO-8859-9">Turkish</option>
    </select>
    </p>
    <p>
    <textarea name="entree_text"></textarea>
    <input type="submit" name="Submit" value="Submit" >
    </p></form>
    and in my jsp :
    // Must set the content type first
    res.setContentType("text/html");
    code = req.getParameter("code");
    example = req.getParameter("entree_text");
    PrintWriter out = res.getWriter();
    // The Servlet send to the Browser the informations to format the language type
    out.println("<html><head><title>Hello World!</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset="+code+"\"></head>");
    // System recover the general Character encoding
    String reqchar = req.getCharacterEncoding();
    out.println("<body><h1>Hello MultiLingual World!</h1>");
    out.println("You have defined an ISO of : "+code);
    out.println("<BR>This is the code of the page that is displayed in this page<BR>");
    out.println("<BR>");
    out.println("<BR>");
    out.println("Character encoding of the page is : "+reqchar);
    out.println("<BR>This is the character code in the Servlet");
    out.println("<BR>");
    out.println("<BR>");
    out.println("<BR>");
    out.println("You have typed : "+example);
    out.println("<BR>");
    out.println("");
    out.println("</body></html>");
    I think starting from this example it is surely easy to modify dynamically the jsp.
    The other possibility would be to use the Weblogic Commerce and the LOCALIZE function, so that you'll have an automatic redirection to the right jsp-encoding depending on the customer's language.
    Feel free to reply on the forum for any related issue.
    Best regards
    Nohmenn BABAI
    BEA EMEA Technical Support Engineer
    "Saurabh" <[email protected]> a écrit dans le message de news: [email protected]...
    Is there any way to set the charset encoding dynamically in a JSP
    page?
    we are using weblogic 6.1 on HP unix.
    is there some way we can set the charset dynamically in the page directive
    <%@ page contentType="text/html;charset=Shift_JIS" %>
    and in MAET tag
    <meta http-equiv="Content-Type" content="text/html" charset="Shift_JIS">
    Saurabh Agarwal[att1.html]

  • Encode/Decode string from unix shell

    Hi,
    I am not sure I'm addressing my question properly, but simply I have a stream where I send commands to a shell and when these commands come back from the input stream they don't mean anything as shown below:
    inc show int status | inc |1/7|1/17|1/19|1/^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H$atus | inc show int status | inc |1/7|1/17|1/19|1/1 ^H^H^H^H^H^H^H^H^H8|1/6|1/8^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H show int status | inc |1/7|1/17|1/19|1/18|1/6|1/8| ^H^H^H^H^H^H^H^H^H1/16|1/15^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^Hstatus | inc |1/7|1/17|1/19|1/18|1/6|1/8|1/16|1/15| ^H^H^H^H^H^H^H^H^H1/13|1/14^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^Hnc |1/7|1/17|1/19|1/18|1/6|1/8|1/16|1/15|1/13|1/14| ^H^H^H^H^H^H^H^H^H1/12|1/11^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H17|1/19|1/18|1/6|1/8|1/16|1/15|1/13|1/14|1/12|1/11| ^H^H^H^H^H^H^H^H^H1/9|1/10
    I am using the utf-8 for encoding...do I need to decode it and how?
    Here is part of my code:
    OutputStreamWriter writer = new OutputStreamWriter(sess.getStdin(), "utf-8");
    writer.write("my string");
    writer.flush();
    class StreamGobbler implements Runnable {
            InputStream is;
            OutputStream oi;
            String type;
            ResultBean resultBean;
            StreamGobbler(InputStream is, String type, ResultBean returnValue) {
                this.is = is;
                this.type = type;
                this.resultBean = returnValue;
            @Override
            public void run() {
                try {
                    InputStreamReader isr = new InputStreamReader(is, "UTF-8");
                    BufferedReader br = new BufferedReader(isr);
                    String line = null;
                    while ((line = br.readLine()) != null) {
                        //System.out.println("TYPE[" + type +  "] COMES FROM STD_OUT THREAD: " + line);
                        this.resultBean.addResultLine(line);
                        this.resultBean.addMessage(line);
                } catch (IOException ioe) {
                    System.out.println("IOE Exception in StreamGobbler");
                    ioe.printStackTrace();
        }Thanks in advance, i never dealt with encoding/decoding text.

    kminev wrote:
    I am pretty sure it is an encoding issue, I'm not convinced because ^H is the ASCII backspace character. Maybe not as I originally thought just some padding but it looks like some form of formatting done the old fashioned way using control characters.
    because if I also send this output in an email format and the email renders it a bit differently, then if I copy and paste the text to html page and render it on the screen it look as it is suppose to be.It's definitely not HTML so this does not seem logical.
    >
    Here are the ios commands I am issuing:
    show int status | inc |gi1/2|gi1/3|gi1/5
    then I send an empty string to the shell so if there is more prompt I see all the outputted values.
    Does that help in any way?
    ThanksSorry I can't help.
    Bye

  • Problems setting the charset encoding via jdbc

    Dear list,
    I would like to know if/how its possible to set the character encoding via the jdbc string, with the oracle thin driver client (classes12.jar).
    Microsoft SQLserver for example supports the addition of a charset="utf-8" for example in the jdbc url.
    Please could tell me how/if this is possible.
    A pasted example would be much appreciated..
    ben bookey

    This bug will be fixed with SP20.
    Regards
    Stefan

  • Issue: Characters / encode /decode & Solution

    Hey guys,
    Few issues on this, I think we will need an encode/decode filter.
    I guess this is related to how if you read a cookie in liquid it converts characters like a comma into its entity (This isn not fixed yet).
    Example:
    <meta property="og:description" content="{{description | strip_html | truncate:200,'...' }}">
    The resulting markup is:
    <meta property="og:description" content="Seven advisers within National Australia Bank's (NAB) salaried advice business, NAB Financial Planning (NAB FP), have transitioned to the bank&rsquo;s newly-launched self-employed model.
    As first ...">
    You can see it has stripped out the html markup but has encoded a ' with it's entity. I can see in some cases this is good but in other cases this is bad. You can also see that <br/> while stripped are treated as new lines instead.
    Liquid itself for these reasons have:
    escape - escape a string
    escape_once - returns an escaped version of html without affecting existing escaped entities
    strip_html - strip html from string
    strip_newlines - strip all newlines (\n) from string
    newline_to_br - replace each newline (\n) with html break
    You only have strip_html but not the other filters. I think if you implemented these then we can address these issues.

    Hi Liam,
    The encoding problem cannot be reproduced. Even in your example, some of the quotes are outputted correctly while a single one not. Can you edit the source of the content and try to re-enter the character from the editor, just to eliminate a possible copy / paste issue from word with a weird character encoding?
    On the new line issue, it seems to happen on some scenarios. For example:
    {{" <div>Seven advisers within National Australia Bank's (NAB) salaried advice business, NAB Financial Planning (NAB FP), have transitioned to the bank's newly-launched's self-employed <br /> model. at first's</div>" | strip_html }} - does not reproduce the problem
    <meta property="og:description" content="{{" <div>Seven advisers within National Australia Bank's (NAB) salaried advice business, NAB Financial Planning (NAB FP), have transitioned to the bank's newly-launched's self-employed <br /> model. at first's</div>" | strip_html }}”> - does reproduce the problem
    Cristinel

Maybe you are looking for

  • Can I download mac os on more than one computer?

    Just was wondering - I have an imac with Snow Leopard, my wife has an older macbook with "leopard" I think.  Can I download my Snow Leopard on her computer? Thanks Stephen

  • HP Updated USB and wireless Lan Failed to install

    my USB Hard drive cant be found and i've noticed the Intel USB 3.0 extensible host controller FAILED to install the update , and also the Ralink Wireless network driver update / LAN also failed to install , i have tryed other USB hard drives and they

  • Problem with IBERT on ZC706

    Hello! I am trying to execute IBERT on ZC706 development kit and facing an error. I followed the steps, given in xtp243.pdf. There is no external hardware and I am doing the loop back test. Can someone please help me rectifying this issue.

  • Oracle 10.2.0.4 Agent error

    Users, Any idea on solving below agent error which is throwing for all versions of DB's: Thread-120121 WARN recvlets.aq: Duplicate threshold key instance_throughput.logons_ps. for [oracle_database <sid>] Oracle On HPUX Monitored Targets Agent: 10.2.0

  • Safari, AppStore, iTunes SSL Connection Problems

    I am using a mid 2011 iMac with Mavericks 10.9.5 installed. Safari Version 7.1 (9537.85.10.17.1) AppStore Version 1.3 (201.7) iTunes Version 11.4 I noticed today the following problem. From Safari I was not able to browse to www.google.com. After som