Tag Archives: Garbled code

Idea unified setting code to UTF-8 code and solution of Tomcat garbled code

Modify project space code

File-> Settings-> Editor-> File encodings
check the bottom box

Modifying the relevant configuration in Tomcat

Step 1: modify Tomcat configuration file and add UTF-8 code

Change the service.xml configuration in Tomcat's conf folder to add URIEncoding="UTF-8", as follows.

<Connector port="8080" protocol="HTTP/1.1" ​ connectionTimeout="20000" ​ redirectPort="8443" URIEncoding="UTF-8"/>

It was found that the start-up condition remained unchanged

Step 2: change the idea configuration and set the encoding to UTF-8

Refer to the above method

Step 3: modify the parameters in logging. Properties under conf of Tomcat

Change java.util.logging.ConsoleHandler.encoding = GBK

to

java.util.logging.ConsoleHandler.encoding = UTF-8

java.nio.charset.MalformedInputException: Input length = 1

Project scenario:

Using springboot to build a personal blog system
reference video: reference video link

Problem Description:

Error reported:

20:40:41.091 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
	at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218)
	at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176)
	at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171)
	at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126)
	at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177)
	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:287)
	at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227)
	at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:195)
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
	at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
	at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:82)
	at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:123)
	at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:507)

Cause analysis:

I remember converting the suffixes of properties files to YML files directly according to the video, and then the Chinese comments on the page became garbled, so I naturally converted them to GBK format, and then the above error was reported

The first possibility is that there is a problem with the encoding format of your application.yml file, which is changed to UTF-8
the second possibility is that your application.yml file is generated by directly changing the suffix of other types of files to YML. At this time, you need to copy all the contents in application.yml, delete them, and then create a new application.yml file, Copy the copied content into it and then run the project, and no error will be reported.

Solution:

Find file coding in the setting of idea

Convert GBK to UTF-8, and then rewrite the Chinese annotation to run normally

Solving Chinese garbled code in Java compressed file

Solving Chinese garbled code in Java compressed file

Introducing Maven dependency

<dependency>
    <groupId>ant</groupId>
    <artifactId>ant</artifactId>
    <version>1.6.5</version>
</dependency>

Click here to view all versions of ant on Maven’s official website

Using ant.jar class in ant

import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;

Replace the class in JDK API

import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

After Oracle 11g is installed, SQL_ Plus.exe The problem of Chinese garbled in command window

Today, after installing Oracle 11g, we encountered sqlplus.exe Command window user login Chinese garbled problem, hope to give yourself a note, also hope to let more people know how to solve. After entering the CMD, right-click the mouse, click properties, find the box as shown in the figure below, and use the old version of the console!

MySQL modify character set

First of all, there are two main concepts about MySQL character set, one is character sets, the other is collations, the former is character content
and encoding, and the latter is some rules for comparing the former. These two parameter sets can be specified at four levels: database instance, single database, table and column.

For users, utf8 encoding is generally recommended to store data. To solve the problem of garbled code, it is not only the storage of MySQL data, but also related to the coding mode of user program files and the connection mode between user program and MySQL database.

first of all, MySQL has a default character set, which is determined during installation. When compiling mysql, you can use default_ Charset =
utf8 and default_ COLLATION=utf8_ general_ CI (MySQL version 5.5, version 5.1 uses — with charset =
utf8 — with collation = utf8)_ general_ The default character set is utf8, which is also the most once and for all method. After this is specified,
the coding mode of client connecting to database is utf8 by default, and the application does not need any processing.

unfortunately, many people don’t specify these two parameters when compiling and installing mysql, and most people install it through binary programs.
at this time, the default character set of MySQL is Latin1. At this time, we can still specify the default character set of MySQL by my.cnf Add two parameters to the file:
1. Add
default character set = utf8 under [mysqld]
2. Add
default character set = utf8 under [Client]
2 In this way, we don’t need to specify utf8 character set when we build database and table. This writing method in the configuration file solves the problem of data storage and comparison
, but it has no effect on the connection of the client. At this time, the client usually needs to specify utf8 connection to avoid garbled code. This is the general set
Names command. In fact, the set names utf8 command corresponds to the following server-side commands:
set character_ set_ client = utf8;
SET character_ set_ results = utf8;
SET character_ set_ Connection = xutf8;
but these three parameters cannot be written in the configuration file my.cnf It’s in the library. It can only be modified dynamically by the set command. What we need is to write a way to
Yongyi in the configuration file. At this time, is there a way to solve the problem on the server?The feasible idea is in init_ Set in connect. This command will be triggered every time an ordinary user connects. You can add the following line in the [mysqld] section to set the connection character set:
Add under [mysqld]:
init_ Connect =’set names utf8 ‘
summary:
1. It is preferred to specify two parameters to use utf8 encoding when compiling and installing mysql.
2. Select in the configuration file my.cnf or my.ini Set two parameters and init at the same time_ Connect parameter.
3. The third is in the configuration file my.cnf or my.ini Set two parameters, and specify the set names command for the client connection.
4. In the configuration file my.cnf The default character set parameter is added to the client and server in to facilitate management.

Solve rstudio software error: fatal error error system error 5 (access denied) problem, pro test effective

1. Error reporting:

2. Error report: because the current system user name is in Chinese, there is a garbled code when reading the path, which cannot be recognized.

3. Solution: modify the values of the current user’s environment variables temp and TMP. Change the variable value to a path without Chinese name.

4. Restart rsudio software: the software can be used normally.