[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

java. non-English characters encoding problem. intellij idea

 
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
SunnyX
Asked:
SunnyX
  • 2
1 Solution
 
CEHJCommented:
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
 
SunnyXAuthor Commented:
thx
0
 
CEHJCommented:
:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now