Golang Web Development When the front end of the riddle of the Blank wrap the pit

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

When using Golang for web development, sometimes rendered templates appear in front of the foreground with some strange whitespace wrapping, the specific feature is to view the CSS style sheet and there is no relevant definition of the blank part.

Analysis:

To view the page source code for the problem page, copy the blank wrap section transcoding to Unicode encoding, and find that it contains the characters "figure I" of \u2028 .

"Figure I"

In addition, directly in the browser to check the inside of the HTML select Edit as HTML, you can also find that there is a small red dot in the white space, the mouse pointer will directly show that the character is \u2028"figure two." Lookup data found that such line breaks are not supported in JavaScript.

"Figure II"

Workaround:

In the Web check can be found that the direct deletion of these red dots can solve the problem. There is a direct front-end processing on the web, that is, to search the page \u2028 and replace it with \\u2028 , of course, you can use the Golang in the background processing, that is, before the output of HTML to retrieve the content, and replace it.

Strings. Replace (HTML,"\u2028", "",-1)

Related Article

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.