C # generation Chinese Traditional Web Page

xiaoxiao2021-03-06  40

C # generation Chinese Traditional Web Page

1 Quote in the project Microsoft.visualBasic.dll

Usually in the .NET Framework Environment Directory such as C: / Winnt / Microsoft.Net / framework /V1.1.4322

/Microsoft.visualbasic.dll.

2 use method

Microsoft.visualBasic.Strings.StrConv ("Instr", Microsoft.visualBasic.vbstrconv.traditionalChinese, System.globalization.cultureInfo.currentculture.lcid);

* The use of this method can be found in the MSDN.

3 Generate the web page Use the code 950, the code is as follows:

// write file

Public Bool Writefile (String filepath)

{

Try

{

IF (filepath == null)

Return False;

This.createdir (filepath.substring (0, filepath.lastindexof ("//"))));

Streamwriter outstream = new streamwriter (filepath, false, system.text.Encoding.getencoding (950));

OutStream.write (Contentstr);

Outstream.close ();

Return True;

}

Catch

{

Return False;

}

}

4 Read the code 936 when reading simplified files

// read the file

Public String Readfile (String FilePath)

{

String restr = "";

IF (filepath == null) Return RESTR;

USING (streamreader sr = new streamreader (filepath, system.text.Encoding.getencoding (936)))

{

String line;

While (line = sr.readline ())! = null)

{

Restr = line "/ r / n";

}

}

Return RESTR;

}

转载请注明原文地址:https://www.9cbs.com/read-78702.html

New Post(0)