Character string truncation method and device

A string and substring technology, applied in the computer field, can solve problems such as string truncation and garbled characters

Active Publication Date: 2014-09-24
TENCENT TECH (SHENZHEN) CO LTD
View PDF5 Cites 15 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0004] In view of this, the main purpose of the present invention is to provide a string truncation method and device to solve the problem of garbled characters in the prior art for string truncation

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Character string truncation method and device
  • Character string truncation method and device
  • Character string truncation method and device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0063] In order to make the above objects, features and advantages of the present invention more comprehensible, the embodiments of the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0064] In the prior art, the character string is usually truncated according to the preset maximum number of bytes, and the truncated character string may display garbled characters. In some character encoding environments, the number of bytes occupied by characters is different. For example, in UTF-8 encoding, a Chinese character occupies 3 bytes, while an English character occupies 1 byte. If the string is truncated according to the maximum number of bytes, when the truncation position is in the middle of 3 bytes of a Chinese character, the Chinese character will be displayed as garbled characters. For example, under UTF-8 encoding, set the maximum intercepted byte length MAX_CHAR_LEN=20, then the ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a character string truncation method which is used for preventing messy codes in a character string truncation process. The method comprises steps as follows: reading a to-be-truncated character string, and acquiring a byte length occupied by a current character; judging whether a substring consisting of characters between an initial character and the current character in the to-be-truncated character string meets a preset truncation condition; if the character substring consisting of characters between the initial character and the current character in the to-be-truncated character string meets the preset truncation condition, subtracting the current character from the substring according to the byte length occupied by the current character, taking a product as a truncated substring, and displaying the truncated substring. The invention discloses a character string truncation device.

Description

technical field [0001] The invention relates to the field of computer technology, in particular to a string truncation method and device. Background technique [0002] In the interface display of some application programs, due to the limitation of the size and position design of the interface text control, it is often necessary to truncate strings of various lengths before displaying them in the text control. In the prior art, it is common practice to preset the maximum number of bytes for character strings of different lengths, and if the number of bytes contained in the string to be displayed exceeds the preset maximum number of bytes, the characters are truncated String, only display the substring consisting of the largest number of bytes before it, and attach an ellipsis to indicate that the displayed content is a truncated substring if necessary. [0003] However, in some character encoding environments, the number of bytes occupied by Chinese, English or other symboli...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F17/22
CPCG06F17/22G06F40/109G06F40/126G06F40/151
Inventor 赵毅申家忠
Owner TENCENT TECH (SHENZHEN) CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products