battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Share
 

 java convert string to unicode

Go down 
AuthorMessage
Admin
Admin
Admin

Posts : 123
Join date : 2011-08-01

java convert string to unicode Empty
PostSubject: java convert string to unicode   java convert string to unicode EmptySun Mar 25, 2018 8:22 pm

java convert string to unicode 273u1z

main "
Code:
import java.util.Scanner;

public class xc {

   public static void main(String[] args) {
      // TODO Auto-generated method stub
      Scanner s1 = new Scanner(System.in);
      System.out.println("enter input");
      String input = s1.nextLine();
      //char [] chars = { '1', 'a', '\u0152'};
      char [] chars = input.toCharArray();
      String result = "";
      for( int i = 0; i < chars.length; i++) {
          System.out.printf(" char = %c  codepoint = \\u%04x \n", chars[i], Character.codePointAt(chars, i));
         result += ("\\u" + Integer.toHexString(chars[i] | 0x10000).substring(1) );
   }
      System.out.println(result);
}
}

_________________
kurayami no kagi :TO:
Back to top Go down
View user profile http://yotamarker.forumotion.com
Admin
Admin
Admin

Posts : 123
Join date : 2011-08-01

java convert string to unicode Empty
PostSubject: java decode unicode string message to regular string   java convert string to unicode EmptySun Mar 25, 2018 8:40 pm

decode :
Code:
import java.io.UnsupportedEncodingException;
import java.util.Scanner;


public class xc {

   public static void main(String[] args) throws UnsupportedEncodingException {
      // TODO Auto-generated method stub
      //Scanner s1 = new Scanner(System.in);
      //System.out.println("enter input");
      //String b = "\u006d\u006f\u0074\u0069\u0020\u0062\u0061\u0072\u0073\u006b\u0069";//s1.nextLine();
      
      String string = "\u006d\u006f\u0074\u0069\u0020\u0062\u0061\u0072\u0073\u006b\u0069";
       byte[] utf8 = string.getBytes("UTF-8");
      
       string = new String(utf8, "UTF-8");
       System.out.println(string);

    }

   }
elephant

_________________
kurayami no kagi :TO:
Back to top Go down
View user profile http://yotamarker.forumotion.com
 
java convert string to unicode
Back to top 
Page 1 of 1
 Similar topics
-
» Cannot locate the class Select in web driver
» Retrieving number of rows in a table

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: