Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to filter Special characters in ut8 Database

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to filter special characters in ut8 database". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The ut8 database cannot save more than 3 bytes of utf characters. A filter is handwritten to specify the maximum character length to be filtered.

UTF-8 Encoding Rule 1 byte 0xxxxxxx 2 bytes 110xxxxx 10xxxxxx 3 bytes 1110xxxx 10xxxxxx 10xxxxxx 4 bytes 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 5 bytes 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 6 bytes 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

Realize

Public static String utf8M (String str, int m) {byte [] bytes = str.getBytes (KtIo.utf8 ()); int len = bytes.length; int off = 0; byte [] buffer = null; byte b; int s; int j, k; int lst = len-1; for (int I = 0; I < len; iTunes +) {b = bytes [I] S = b & 0XFF; if (s < 192) {if (buffer! = null) {buffer [off++] = b;}} else {if (s < 224) {j = 1 } else if (s < 240) {j = 2;} else if (s < 248) {j = 3;} else if (s < 252) {j = 4;} else if (b < 254) {j = 5 } else {I + = 6; continue;} if (j < m) {/ / allowed character length j + = I If (buffer! = null) {buffer [off++] = b; k = j < lst? J: lst; for (iTunes)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report