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
» text art canvas
Today at 8:55 pm by Moti Barski

» android mobile app dev APK
Today at 7:00 pm by Moti Barski

» links/suggestions to become a programmer
Mon May 07, 2018 11:01 pm by Moti Barski

» java eclipse oxygen grimoire
Thu May 03, 2018 8:24 pm by Moti Barski

» forum logo by tf monkey
Wed May 02, 2018 10:17 pm by Moti Barski

» java and MySQL
Mon Apr 30, 2018 3:02 pm by Admin

» mini A.I puzzles
Mon Apr 23, 2018 11:38 am by Moti Barski

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

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

June 2018
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
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 : 108
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 : 108
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: