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
» android mobile app dev APK
Yesterday at 10:01 pm by Moti Barski

» battle programmers alliance new features :
Yesterday at 5:25 pm by Admin

» urban prepper grimoire
Sat Aug 18, 2018 1:03 pm by Moti Barski

» broadcast receiver dead
Sat Aug 04, 2018 7:51 am by Moti Barski

» programming tool : find dif between 2 texts
Tue Jul 31, 2018 6:32 am by Moti Barski

» java class that filter numbers out of a string
Mon Jul 30, 2018 11:20 am by Moti Barski

» android studio execises
Mon Jul 09, 2018 1:43 pm by Moti Barski

» problem with firebase authentication
Thu Jun 28, 2018 9:52 am by Moti Barski

» text art canvas
Wed Jun 20, 2018 8:55 pm by Moti Barski

August 2018
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031 
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 : 113
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 http://yotamarker.forumotion.com
Admin
Admin
avatar

Posts : 113
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 http://yotamarker.forumotion.com
 
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: