Mono: solves Chinese problems

Source: Internet
Author: User

After publishing a series of articles in the Mono Development Guide last year, I basically didn't write any more about Mono. I have been mainly engaged in Java platforms in the last two years, and I rarely used dotnet. Another problem is that the Chinese version of Mono makes me spend little time on it.

When I used Mono in the past, I tried my best to avoid Chinese characters by reading examples in my previous articles. The cs file I wrote does not contain any Chinese characters. This is because the previous Mono internationalization was too weak. Many of my friends sent me an email asking me how to handle the Chinese language. I didn't know how to solve it at the time. I submitted a bug in Mono's bugzilla, but I didn't see closed for a long time, so I didn't reply back to these friends, And said soory again.

Now, Mono can better deal with international problems. I am also posting my research experiences here, hoping to share and discuss with friends who love Mono and dotnet.


First, let's talk about my environment: asus + fedora 3 + Mono 1.1.

Set all Locale to zh_CN.gb2312.

In this article, I will first introduce how to deal with Chinese problems that have plagued everyone before. In the next article, I will introduce the internationalization of programs.

 

Use monodevlop to create a Console project named Test.

Edit the Main. cs file:

Using System;

 

Class MainClass

{

Public
Static void Main (String [] args)

{

Console. WriteLine ("Brother's email address is: smallnest@gmail.com ");

}

}

Run in monodevelop and the correct result is displayed in the output window.

 

Open the terminal, go to the./bin/Debug directory, and run mono Test.exe.Garbled. This is related to my environment settings. Set the terminal encoding to utf8 and then run mono.
Test.exe. The result is displayed.Normal.

 

The above compilation is compiled through monodevelop. compile it manually below and try the result.

Go to the Main. cs Folder:

Mcs Main. cs

After the command is executed, the main.exe file will be generated to run the file.

Mono Main.exe

The output result isGarbled(Whether the terminal code is gb2312 or utf8 ).

 

Compile by setting the code page:

Mcs-codepage: utf8 Main. cs

After the command is executed, the main.exe file will be generated to run the file.

Mono Main.exe

The output result isNormal(The Terminal code is utf8 ).

 

Tips:

Every time you run the mono compiled program, you must use mono *. exe. This is troublesome. We can create File Associations in Linux.

Run the following shell and you don't have to run the mono file every time.

if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
     /sbin/modprobe binfmt_misc mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
fi 
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
     echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
else
     echo "No binfmt_misc support" exit 1
fi

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.