Incorrect character encoding in dist jar created with NetBeans

I finally wrote me a small application. This is a desktop application, but it has a built-in web server. When I dined from NetBeans, everything is fine. When I have lunch at the bank, I have the correct character encoding in the GUI, but the output of the web server is damaged ("?" Instead of national characters).

I am using NetBeans 6.7.1, jdk1.6.0_16, http server from Java 6 SE and lib Rome 1.0

I do not put any source code here because I do not know which part I should put.

// edit: data is hard-coded in Strings. These lines are passed to Rome as arguments to create the RSS nodes, Romes RSS feeds are written to String, and then the lines are passed to HttpHandler.

+3
source share
2 answers

This question probably has nothing to do with NetBeans. Typically, character encoding problems are caused by the fact that somewhere the character encoding is not determined, in which case the actual character encoding will be determined largely by luck.

For example, Java Stringsis internal UTF-16, but the encoding used by Java Readersis defined by default for the platform, unless explicitly specified.

+2
source
  • Check the encoding in the source files .
  • , / ( , String -> byte[] byte[] -> String). , , myEncoding -> UTF-16.
  • , , /.
  • XML, , , (<?xml version="1.0" encoding="UTF-8"?>).
  • HTTP, , charset header (, Content-Type: text/html; charset=utf-8). MIME- (, application/rss+xml ). MIME.
+3

Source: https://habr.com/ru/post/1724709/


All Articles