[Conclusion] Page garbled characters in Asp.net

Source: Internet
Author: User

1. <globalization
Requestencoding = "gb2312"
Responseencoding = "gb2312"
Fileencoding = "gb2312"
/>

Or

<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">

If the language and culture cannot be added
. <Globalization
Requestencoding = "gb2312" responseencoding = "gb2312" fileencoding = "gb2312" Culture = "En-Au"
/>
En-Au is the Australian Language and Culture code

2. Specify the file name when downloading the file. Is the Chinese file name garbled?

Response. addheader ("content-disposition", "attachment; filename =" + httputility. urlencoding (filename. tostring ()));

 

3. How to identify whether a string contains Korean

Http://search.csdn.net/Expert/topic/2456/2456407.xml? Temp =. 5485498.

If only English and Korean are supported
/******* This function returns the character strings except English *********/
Create Function Test (@ A varchar (20 ))
Returns varchar (20)
As
Begin
Declare @ B varchar (20), @ I int
Set @ B =''
Set @ I = 1
While @ I <= Len (@)
Begin
If upper (substring (@ A, @ I, 1) not between 'A' and 'Z'
Set @ B = @ B + substring (@ A, @ I, 1)
Set @ I = @ I + 1
End
Return @ B
End

Select DBO. Test ('abc12dsa451 ')


--------------------
12451

(The number of affected rows is 1)
-- 1. for multi-country texts, be sure to use Unicode to judge!
-- 2. Korean Unicode split: 12592-> 12687 44032-> 55203
Websites: http://www.buja.8u8.com/eeeeee.htm

Create Function HW (@ STR nvarchar (100 ))
Returns int
As
Begin
Declare @ A int
Set @ A = 0
While @ STR <> ''and @ A = 0
Begin
Set @ A = (case when Unicode (left (@ STR, 1) between 12592 and 12687
Or Unicode (left (@ STR, 1) between 44032 and 55203
Then 1
Else 0 end)
Set @ STR = right (@ STR, Len (@ Str)-1)
End
Return @
End

-- Call:
Declare @ A nvarchar (100)
Set @ A = n' ABC in & #44035; country 1000'
Select DBO. HW (@)

-- Return: 1

Set @ A = n' ABC China 123'
Select DBO. HW (@)

-- Return: 0

 

4. Why are the Chinese characters read from the file garbled?

System. Io. streamreader m_fs = system. Io. file. opentext (hfile_selectfile.value );
Change
System. Io. streamreader m_fs = new system. Io. streamreader (hfile_selectfile.value, system. Text. encoding. getencoding ("gb2312 "));

5. jmail sends an email attachment or does not exist or garbled characters in the body.

Http://community.csdn.net/Expert/topic/3172/3172047.xml? Temp =. 3463404.

6. How can I solve the problem of Chinese garbled characters in query strings?

The query content is encoded by server. urlencode.

String url = "http: // localhost/test. aspx? A = "+ server. urlencode (" James ");
Solution
--> Server. urldecode ()

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.