battle programmers alliance

battle programminga forum for elite programmerswith extreme will powerto sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Search
 
 

Display results as :
 
Rechercher Advanced Search
Latest topics
» mini A.I puzzles
Mon Apr 23, 2018 11:38 am by Moti Barski

» java and MySQL
Sun Apr 15, 2018 8:57 pm by Moti Barski

» java convert string to unicode
Sun Mar 25, 2018 8:40 pm by Admin

» java eclipse oxygen grimoire
Sat Mar 24, 2018 8:31 pm by Admin

» problem java dynamic web
Sat Mar 24, 2018 6:10 am by Admin

» auto programming dev
Wed Mar 14, 2018 8:42 pm by Admin

» JAVA design patterns
Wed Mar 07, 2018 9:53 pm by Admin

» vb.net morse ear with net lingo beef up:
Sun Mar 04, 2018 10:30 pm by Moti Barski

» java concept input output class
Tue Feb 20, 2018 7:21 pm by Admin

April 2018
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
2930     
CalendarCalendar
Social bookmarking
Social bookmarking digg  Social bookmarking delicious  Social bookmarking reddit  Social bookmarking stumbleupon  Social bookmarking slashdot  Social bookmarking yahoo  Social bookmarking google  Social bookmarking blogmarks  Social bookmarking live      

Bookmark and share the address of battle programmers alliance on your social bookmarking website
Share | 
 

 java convert string to unicode

Go down 
AuthorMessage
Admin
Admin
avatar

Posts : 105
Join date : 2011-08-01

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



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  _____    
Back to top Go down
View user profile https://yotamarker.justforum.net
Admin
Admin
avatar

Posts : 105
Join date : 2011-08-01

PostSubject: java decode unicode string message to regular string   Sun 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  _____    
Back to top Go down
View user profile https://yotamarker.justforum.net
 
java convert string to unicode
Back to top 
Page 1 of 1
 Similar topics
-
» Convert string (with decimal or a point) to a integer.
» Verify command when used with Java,JUNIT and Eclipse
» selenium RC
» opera browser not loading the page using selenium Rc(Java)
» String comparison using Selenium Ide

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