Modify the code so that the thtmllabel control of the TMS Component Library supports Chinese line breaks.

Source: Internet
Author: User

Recently, when using the thtmllabel control, we found that if the text contains Chinese characters, the control cannot provide good line breaks. This control does not have the wordwrap attribute either. ViewSource codeThe following situations are found:

1, wordwrap = Not ellipsis;

Although this control does not have the wordwrap attribute, the setting value of the ellipsis attribute affects the wordwrap behavior.

If ellipsis is true, the excess part is displayed as... but the line feed is not displayed.

If ellipsis is false, a line break is displayed in excess of the limit. The problem is that a line break is allowed in English and a line break is unavailable in Chinese.

 

2. spacepos: = pos ('', S );

Continue tracking and find that there is a above near line htmllengo. Pas 600CodeThat is to say, the automatic line feed is dependent on spaces, and in English habits, words cannot be wrapped. There are few spaces in Chinese statements, so line feed fails.

 

Modification Method (near htmllengo. Pas line 600 ):

 

// The original code looks down. // If wordwrap then begin // spacepos: = pos (',', S) // end else // spacepos: = 0; // Replace the following code with if wordwrap then begin if S = ''then spacepos: = 0 else begin if ord (s [1]) <127 then spacepos: = pos ('', S) else spacepos: = 1; end else spacepos: = 0;

Note: The Source Code may vary depending on the version number of the control. My version is: TMS pack. v5.2.4.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.