Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

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: 2016-03-16
TENCENT TECH (SHENZHEN) CO LTD
View PDF5 Cites 0 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
  • String truncation method and device
  • String truncation method and device
  • 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

Methods, apparatus, and terminal devices for truncating a character string are provided. A character string to be truncate is read and a byte length occupied by a current character is obtained. It is determined whether a substring, formed from a starting character of the character string to be truncated to the current character, satisfies a pre-set truncating condition. When the substring, formed from the starting character of the character string to be truncated to the current character, satisfies the pre-set truncating condition, the current character is subtracted from the substring to generate a truncated substring for displaying, according to the byte length occupied by the current character.

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 Patents(China)
IPC IPC(8): G06F17/22
CPCG06F40/109G06F40/126G06F40/151
Inventor 赵毅申家忠
Owner TENCENT TECH (SHENZHEN) CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products