Solved

java. non-English characters encoding problem. intellij idea

Posted on 2016-10-09
3
98 Views
Last Modified: 2016-10-10
 
package com ; 
import java.io.UnsupportedEncodingException;

/**

 */
public class NewHW {
    public static void main(String[] args) throws UnsupportedEncodingException {
   System.out.println(   System.setProperty("file.encoding", "cp-1252")    );
    String s1 = "Përshëndetje botë!";

    byte[] bytes = s1.getBytes("utf-8");

    String s2 = new String(bytes, "cp1252");
    System.out.println(s2);
}
}

Open in new window


EXPECTED output: Përshëndetje botë!
Actual output: Përshëndetje botë!

Tried to get output in Albanian Hello World. However, the code above doesn't give me expected output. Please tell how should I change my code to meet my expectation.
I use windows 10.

Thanks in advance !
0
Comment
Question by:SunnyX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 41835858
If what is in your editor actually looks like this (which is how it looks when i view this question page in a browser), then it's firstly a problem with the encoding used in your editor.

'Albanian'and you should fix that in your IDE's editor settings

This may be Albanian btw, but there is only one special character - "small letter e with diaresis". As such, that's not very exotic at all and most character encodings will deal with it perfectly well and so the following app should work in most cases:


public class Alb {
    public static void main(String[] args) {
        String s = "P\u00ebrshendetje Bot\u00eb";
        System.out.println(s);
    }
}

Open in new window

0
 

Author Closing Comment

by:SunnyX
ID: 41836688
thx
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41836847
:)
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question