Encode, Decode issue

Hi, Guys
I have met a strange problem.Please help me.
I access a web service server in EU via axis.
I am in Canada.
(also create Java file via web service xml file).
I get a string from web service, if I print it out via
System.out.println, It looks pretty good.
Since I also want to transfer this string to Mobile device.
I want to change it to byte. The problem is:
When I use String.getBytes(), it add some strange character
to the head and end, for example:
if System.out.println, it looks "London St"
if I use string.getBytes(), the byte[] looks like "&&London St&&"
if I use string.getBytes("UTF-8"), it looks like "%%%London St%%%"
I have checked their demo, the xml encode is UTF-8.
what is the problem?
My platform is: windows 2000, I don't know web service platform.
My developer is JDeveloper10g, even if I deploy jar to Tomcat,
It still gives me same result.
Any suggestion would be great accepted.

Hi Guys,
I have tried and take look at the source again.
First answer for malcolmmc
>>Are you using a proper XML reader?
since the webservice Java class are extended from apache AXIS.
and create a call extended from java.xml.xxxxx
so I assume that this is java standard xmlreader.
it should be good.
Second answer AjaySingh516
do it youself and let me know the result.
byte[] data = string.getBytes();
String temp = new String(data, 0, data.length)I have tried it, and the result is no.
since when calling the string.getbytes(),
it will return the byte that contains extoic character.
so when calling data.length, it will calculate the extoic character.
Thanks guys.
Anything that I can try

Similar Messages

  • 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

  • Base 64 Encode/Decode

    I consider sending clear text problematic when the data ends
    up as XML information. Converting the text Strings to Base 64
    between PHP and Flex 2 (or anything else and Flex 2) eliminates
    issues with character text like <> and &'s. I've done a
    lot of XMLRPC coding and always sent text data values that are Base
    64 format. The built in Flex 2 Base 64 functions make this easier.
    On the PHP side, you can use
    $b64StringVal = base64_encode ( $stringData );
    $stringData = base64_decode ( $b64StringVal );
    to convert.
    If you are using Java at th back end, look at:
    http://iharder.sourceforge.net/current/java/base64/
    Definitions in the CDATA area:
    import mx.utils.Base64Encoder;
    import mx.utils.Base64Decoder;
    import flash.utils.ByteArray;
    public function encodeB64(target:String) : String
    var be:Base64Encoder = new Base64Encoder();
    be.encode(target);
    var encodedData:String = be.flush();
    return encodedData;
    public function decodeB64(target:String) : String
    var bd:Base64Decoder = new Base64Decoder();
    bd.decode(target);
    var decodedData:ByteArray = bd.drain();
    return decodedData.toString();
    [Bindable] public var myData:String = new String();
    private function loginResult(evt:ResultEvent):void {
    var b64MyData:String = evt.result.MyData;
    myData=decodeB64(b64MyData);
    In the mxml area:
    <mx:HTTPService id="loginPage" url="
    http://localhost/xxx.php"
    useProxy="false" method="POST" />
    <mx:Model id="loginModel1">
    <root>
    <loginModel>"loginModel1"</loginModel>
    <username>{encodeB64(username.text)}</username>
    <password>{encodeB64(password.text)}</password>
    </root>
    </mx:Model>

    Hello jlmoller,
    Have you ever had an issue where the encoding / decoding
    process ended up prepending the string with extra characters?
    This is happening to me
    Erik

  • 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

  • How to encode/decode URLs ...

    Hello,
    I wanted to send an entire URL as parameter to a Stored Procedure.
    How can I encode/decode this URL?
    Thanks
    Madhav

    I don't know of an encoder, but IBM alphaWorks has a decoder:
    http://www.alphaworks.ibm.com/tech/mpeg-4

  • ASN.1 encoder/decoder

    Hi All,
    I have a asn.1 definition file.
    I need to encode/decode the a file with the help of the above definition file. I tried using JavaAsn1Compiler, this compiler fullfill all my requirments except the one GraphicString type is not supported in this compilier.
    Can any body suggest me a asn.1 encoder/decoder.
    Thanks in advance.
    Asif

    Pranitha wrote:
    We already used nokalva for OSS file parsing. From now onwards we dont want to use third party tools, is there any hand written code avialable for parsing an ASN.1 file using java.What part of my last reply did you not understand?
    The java API does not contain anything for ASN.
    Everything outside of the Java API would be consider third party.
    So either explain exactly what it is that you want without using the term "third party" or recognize that what you are asking does not exist.

  • Invalid Session ID - cookie encode/decode

    Hello,
    I'm looking for the correct combination of cookie encode/decode parameters for my own setup.
    Machine am : AM Server 7.0 on WS6.1
    Machine amc : my own webapps using AM client SDK & protected by a Policy agent. 2.2 Everything within a WS6.1 container.
    After being redirected to AM, I obtain my iPlanetDirectoryPro cookie and my webapp can obtain a SSOToken using the SSOToken token = manager.createSSOToken(String) if obtain the String via Cookie accessor's method.
    No luck with SSOToken token = manager.createSSOToken(HttpServletRequest) which always gives a Invalid Session Id message. I know that this is an encoding problem but I tried many combinations & heard that these settings are not always well documented. I have at the moment :
    am server AMConfig.properties :
    com.iplanet.am.cookie.encode=false
    am client sdk AMConfig.properties :
    com.iplanet.am.cookie.encode=false
    policy agent AMAgent.properties :
    com.sun.identity.agents.config.sso.decode = false
    com.iplanet.am.cookie.encode = false
    Has somebody worked that out ?
    Thanks !
    nieuwenj

    Hi, am using this code:
    AMUtil.java
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.IOException;
    import javax.security.auth.callback.Callback;
    import javax.security.auth.callback.ChoiceCallback;
    import javax.security.auth.callback.NameCallback;
    import javax.security.auth.callback.PasswordCallback;
    import javax.security.auth.callback.TextInputCallback;
    import javax.security.auth.callback.TextOutputCallback;
    import javax.security.auth.callback.UnsupportedCallbackException;
    import com.sun.identity.authentication.AuthContext;
    import com.sun.identity.authentication.spi.AuthLoginException;
    import com.iplanet.am.util.Debug;
    * @author hjimenez
    public class AMUtil {
        private String loginIndexName;
        private String orgName;
        private String user;
        private String password;
         * Creates a new instance of AMUtil
        public AMUtil(String loginIndexName, String orgName) {
            this.loginIndexName = loginIndexName;
            this.orgName = orgName;
        protected AuthContext getAuthContext()
        throws AuthLoginException, com.iplanet.sso.SSOException, Exception {
            AuthContext lc = new AuthContext(orgName);
            AuthContext.IndexType indexType = AuthContext.IndexType.MODULE_INSTANCE;
            lc.login(indexType, loginIndexName);
            debugMessage(loginIndexName + ": Se obtuvo login context");
            return lc;
        private void addLoginCallbackMessage(Callback[] callbacks)
        throws UnsupportedCallbackException {
            int i = 0;
            try {
                for (i = 0; i < callbacks.length; i++) {
                    if (callbacks[i] instanceof TextOutputCallback) {
                        handleTextOutputCallback((TextOutputCallback)callbacks);
    } else if (callbacks[i] instanceof NameCallback) {
    handleNameCallback((NameCallback)callbacks[i]);
    } else if (callbacks[i] instanceof PasswordCallback) {
    handlePasswordCallback((PasswordCallback)callbacks[i]);
    } else if (callbacks[i] instanceof TextInputCallback) {
    handleTextInputCallback((TextInputCallback)callbacks[i]);
    } else if (callbacks[i] instanceof ChoiceCallback) {
    handleChoiceCallback((ChoiceCallback)callbacks[i]);
    } catch (IOException e) {
    e.printStackTrace();
    throw new UnsupportedCallbackException(callbacks[i],e.getMessage());
    private void handleTextOutputCallback(TextOutputCallback toc) {
    debugMessage("Se ejecut� TextOutputCallback");
    // Mostrar mensaje de acuerdo al tipo especificado
    switch (toc.getMessageType()) {
    case TextOutputCallback.INFORMATION:
    debugMessage(toc.getMessage());
    break;
    case TextOutputCallback.ERROR:
    debugMessage("ERROR: " + toc.getMessage());
    break;
    case TextOutputCallback.WARNING:
    debugMessage("WARNING: " + toc.getMessage());
    break;
    default:
    debugMessage("Tipo de mensaje no soportaado: " +
    toc.getMessageType());
    private void handleNameCallback(NameCallback nc)
    throws IOException {
    // asignar usuario
    nc.setName(this.user);
    private void handleTextInputCallback(TextInputCallback tic)
    throws IOException {
    // poner un prompt para obtener datos
    System.out.print(tic.getPrompt());
    System.out.flush();
    tic.setText((new BufferedReader
    (new InputStreamReader(System.in))).readLine());
    private void handlePasswordCallback(PasswordCallback pc)
    throws IOException {
    // asignar password
    String passwd = this.password;
    pc.setPassword(passwd.toCharArray());
    private void handleChoiceCallback(ChoiceCallback cc)
    throws IOException {
    // ignorar el valor default dado
    System.out.print(cc.getPrompt());
    String[] strChoices = cc.getChoices();
    for (int j = 0; j < strChoices.length; j++) {
    System.out.print("choice[" + j + "] : " + strChoices[j]);
    System.out.flush();
    cc.setSelectedIndex(Integer.parseInt((new BufferedReader
    (new InputStreamReader(System.in))).readLine()));
    public boolean login(AuthContext lc)
    throws UnsupportedCallbackException {
    boolean succeed = false;
    Callback[] callbacks = null;
    // obtener informaci�n del m�dulo solicitada
    while (lc.hasMoreRequirements()) {
    callbacks = lc.getRequirements();
    if (callbacks != null) {
    addLoginCallbackMessage(callbacks);
    lc.submitRequirements(callbacks);
    if (lc.getStatus() == AuthContext.Status.SUCCESS) {
    System.out.println("Login exitoso.");
    succeed = true;
    } else if (lc.getStatus() == AuthContext.Status.FAILED) {
    System.out.println("Login fallo.");
    } else {
    System.out.println("Estatus desconocido: " + lc.getStatus());
    return succeed;
    public void logout(AuthContext lc)
    throws AuthLoginException {
    lc.logout();
    System.out.println("Log Out!!");
    static void debugMessage(String msg) {
    System.out.println(msg);
    public String getUser() {
    return user;
    public void setUser(String user) {
    this.user = user;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    and call it from:
    import com.iplanet.sso.SSOToken;
    import com.sun.identity.authentication.AuthContext;
    import com.sun.identity.authentication.spi.AuthLoginException;
    import javax.security.auth.callback.UnsupportedCallbackException;
    import com.iplanet.sso.SSOException;
    import java.net.InetAddress;
    * @author hjimenez
    public class TestLogin {
        /** Creates a new instance of TestLogin */
        public TestLogin() throws SSOException {
         * @param args the command line arguments
        public static void main(String[] args) {
            try {
                // arg0 = LDAP arg1 = tecnet
                AMUtil login = new AMUtil(args[0], args[1]);
                // arg2=usuario arg3=pass
                login.setUser(args[2]);
                login.setPassword(args[3]);
                AuthContext lc = login.getAuthContext();
                if (login.login(lc)) {
                    SSOToken token = lc.getSSOToken();
                    System.out.println("Token asignado: "+token.getTokenID().toString());
                    String host = token.getHostName();
                    java.security.Principal principal = token.getPrincipal();
                    String authType = token.getAuthType();
                    int level = token.getAuthLevel();
                    InetAddress ipAddress = token.getIPAddress();
                    long maxTime = token.getMaxSessionTime();
                    long idleTime = token.getIdleTime();
                    long maxIdleTime = token.getMaxIdleTime();
                    System.out.println("SSOToken host name: " + host);
                    System.out.println("SSOToken Principal name: " +
                            principal.getName());
                    System.out.println("Authentication type used: " + authType);
                    System.out.println("IPAddress of the host: " +
                            ipAddress.getHostAddress());   
                    login.logout(lc); 
            } catch (AuthLoginException e) {
                e.printStackTrace();
            } catch (UnsupportedCallbackException e) {
                e.printStackTrace();
            } catch (SSOException e) {
                e.printStackTrace();
            }  catch (Exception e) {
                e.printStackTrace();

  • HTML Encode/Decode FLEX

    Is anyone familiar with classes that support html
    encoding/decoding in AS3 or Flex?
    Similar to:
    http://meyerweb.com/eric/tools/dencoder/
    what is being done here?

    Most folks float an Iframe over a spot in the SWF.

  • Using PXI-5431and PXI-1411 to test MPEG-2 encoder/decoder

    I am looking into a way to test an MPEG-2 encoder/decoder.  I have found the PXI-5431, that can generate a NTSC signal which is what I need and the PXI-1411.  So, I guess my question is: would this be a good set up to use the 5431 to generate a signal and the 1411 to acquire the signal and do some comparisons to the two.  Has anyone done this type of testing?  What type of comparisons could be done to the two video signals to verify signal quality(I know very little about video signals)? Or maybe acquire using the PXI-5122?
    Thanks,
    Brian

    Hi BrianPack,
    I have some questions.  Please be much more detailed and specific in your next response.  Try not to use pronouns.  Instead, every time you want to use the word "it" or "card", instead use the proper names, such as the "PXI-5122".
    What card are you referring to in your first sentence?
    When you say (it) "can be configured to decode and encoded MPEG video", do you mean to say you are attempting to encode analog video?
    With all the MPEG encoding and decoding, which cards are you referring to?  Your two cards, or two NI modules?
    When you generate into the encoder, are you wanting to generate from the NI 5431?  If this is true, what video standard are you wanting to use?
    The Frequency Response, Video Resolution, SNR, and composite signal amplitude measurements should be available with the NI 5122 and MicroLEX VideoMaster.  I'm not sure about the NI 1411 because I only support NI's Modular Instruments, but here are the specification sheets for VideoMaster:
    http://www.microlex.dk/products/video/videomaster-component.pdf 
    If you want more information on the NI 1411, it would be best to post a message on the IMAQ/Vision forum.  For now, please respond with more specific information and I'll be happy to assist you!
    Chad Erickson
    Applications Engineer

  • Simple and very fast encoder-decoder

    I will explain my need with an example;
    www.domain.com/photo.jsp?id=23
    here id is 23 and people can try every photo by incresing or decreasing the id number. I want to encode the id's while printing the id to screen as url and will decode everytime when i get the request from user.
    So i need a very fast and simple logic of encode & decode. I have tested base64 at java but everyone knows the algortihm. Is there any other simple algorithm that i can generate on my own?
    What do you advice to me except changing my database and search with hex keys?

    believe me its strictly
    needed on a photo web site... there are too much
    reasons.I can't think of one.1)when ids are sequantial on db users can get the idea which after or before this photo is uploaded
    2)when you see the normal integer numbers on ids you can remember it easily and edit the link by hand and see whats going on...
    3)When u see user_id is=1 u can understand easily that he is an admin or one of the first member of website
    4)when u try the maximum photo id or user id every user can understand how many user or photos are there in website
    there are lots of things like above... They may be not that valueble for everyone but i think this have to be.

  • 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;
    }

  • 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.

  • PSD Encoder/Decoder

    I need a psd encoder/decoder so I can deal with these files in my XMP project.
    Can anyone point me to a fee one? I ideally I'd like to be able to use it with GDI+ and C++.Net 2003 but this might be asking for too much.
    Regards
    RB

    Mike,
    I downloaded simple psd and trying to append functionality to decode layer information.
    Has this already been done ? 
    CT

  • Audio/Video encode & decoding

    I am very new to mac environment,
    and have a background as a linux developer. I worked mostly with avcodec and avformat api's (from ffmpeg project) to manipulate media. I could reach media devices/streams using oss, alsa, v4l or v4l2 interfaces/drivers and encode/decode them with avcodec API. Now I switched to mac and I want to get audio/video frames from input devices and encode/decode them as I want. I already took a look at QTkit and QT related topics but there is no codec variation and also no control of frames which has taken from input device/file. There is no flexibilty with almost just one way to encode media (h264 and AAC, with predefined bitrates). I am using snow leopard with Xcode 4 so AVfoundations is avaliable just for IOS env. and not for Mac environment.
    I can not find any detailed media encoding/decoding document or usable(flexible) framework in mac developer central. Please help me to find or give me some advice about mac environment.
    Thanks in advance .

    First of all thank you xnav. But I already searched for AVFoundations and related sample sources. I do not want to change my operating system and I do not want to believe that MacOS has not got a framework embracing the media related functions at all before Lion. As I mentioned in the text above I am using snow leopard.
    By the way I want to reach full control over media streams/frames and codec parameters. I want to be able to decode media stream/frame if it is encoded (for example: a web cam streaming jpeg captures using hw codec) I want to decode and resize it, maybe view it in a frame and encode it again and store it in a file or directly stream over rtsp. Is it possible ? Does't Apple have such a framework which I can find in open source environment easily (for example: ffmpeg - avcodec - avformat - avdevice). Device/driver level tools and codecs can be inside different frameworks but there must be some tools for it.

  • XML Encoder/Decoder

    Hi!
    First ..... can XML Encoder/Decoder persist the data in a jTextPane?
    .... and if so ... why doesnt this code work? ... it writes the xml file(not much in there to see) , but I cant read back to my jTextPane .
    package AddRFSwitchPac;
    import java.beans.XMLEncoder;
    import java.io.BufferedOutputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import javax.swing.text.StyledDocument;
    * @author Richard
    public class XMLTextPaneSaveStart {
        /** Creates a new instance of XMLTextPaneSaveStart */
        public XMLTextPaneSaveStart() {
            XMLEncoder e;
            StyledDocument doc1 = (StyledDocument)AddRFSwitchMain.jTextPane1.getDocument();
            try {
                e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("docStart.xml")));
                e.writeObject(doc1);
                e.flush();
                e.close();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
    package AddRFSwitchPac;
    import java.beans.XMLDecoder;
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import javax.swing.text.StyledDocument;
    * @author Richard
    public class XMLTextPaneRestoreStart {
        /** Creates a new instance of XMLTextPaneRestoreStart */
        public XMLTextPaneRestoreStart() {
            StyledDocument doc1 = (StyledDocument)AddRFSwitchMain.jTextPane1.getDocument();
            try {
                XMLDecoder d = new XMLDecoder(new BufferedInputStream(new FileInputStream("docStart.xml")));
                doc1 = (StyledDocument)d.readObject();
                d.close();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
    }

    When I use "ObjectInput/Output streams" .... works fine....
    try {
          //File WRITER 
          FileOutputStream fos = new FileOutputStream ("docStart.ser");
          ObjectOutputStream oos = new ObjectOutputStream (fos);
          oos.writeObject (doc1); // doc1
          oos.flush();
          oos.close();
          System.out.println("jTextPane1 Saved to Disk");
        } catch (IOException e) {
          System.out.println("jTextPane1 Un-Able to Save!!");
          e.printStackTrace();
    try {
          FileInputStream fis = new FileInputStream ("docStart.ser");
          ObjectInputStream ois = new ObjectInputStream (fis);
          doc1 = (StyledDocument)ois.readObject();
          AddRFSwitchMain.jTextPane1.setStyledDocument ((StyledDocument) doc1);
          ois.close();
           System.out.println("jTextPane1 ReLoaded from Disk");                    
        } catch (Exception e) {
           System.out.println("jTextPane1 Un-Able to ReLoad");                                      
          e.printStackTrace();
    }But , .....cant I save this jTextPane using XML ??

Maybe you are looking for

  • Itunes connects to wrong countrys store

    My Itunes will only connect to the US store, but I am a UK user (and wish to connect to the UK store). I have tried to reinstall itunes and searhed for options within the program, but have had no luck. Can anyone help?

  • Error Message When Trying to Download Adobe Media Player

    I can not download Media Player. I've tried using Internet Explorer and Mozilla Firefox. I receive an error message that says . . . "Sorry and error has occurred. The application could not be installed. Try installing it again. If the problem persist

  • 8520, Media Card

    I am trying to format my media card. I went to options and the media card does not show up in the list. There is a Memory and in that it says media card. Should I format it that way? Or should Media Card be listed under options? The phone showed that

  • Why are Unicode Characters not displaying properly anymore ?

    Hi, I've just update my firefox Mac version 19.0 to 20.0. The big problem is I cannot see our Burmese Unicode character anymore. I can see burmese character at ( www.facebook.com/futurewayeducation ) with 19.0 without doing any setting but with 20.0,

  • Error in connecting to SLD

    Hi All, I am trying to create the Jco destinations as part of the ESS and MSS configurations.But, when i login to http://hsotname:port/webdynpro/resources/sap.com/tc~wd~tools~admin/Explorer i am getting the below error. I have checked SLD status in h