非常急!!!!! 一个简单的问题

shena 2003-11-21 11:48:29
请问有什么办法在VB中将ascii的格式专成UTF8格式的?

谢谢!
...全文
31 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengyetianshi 2003-11-22
  • 打赏
  • 举报
回复
UP
踏平扶桑 2003-11-21
  • 打赏
  • 举报
回复
up
没听过utf8:)
海牛 2003-11-21
  • 打赏
  • 举报
回复
Up
cfan246 2003-11-21
  • 打赏
  • 举报
回复
编码好像 不是 很简单阿
shena 2003-11-21
  • 打赏
  • 举报
回复
大家看看,这段代码能不能反过来用啊?


Dim ANSIString() As Byte, MyEncoder As New System.Text.ASCIIEncoding()
Dim fFile As IO.File, fStream As IO.FileStream

' Set the source string and filename
Dim sSourceString As String = "Hello, World! This is a test!"
Dim sFilename As String = "C:\test.txt"

' Store the ANSI encoded string in ANSIString
ANSIString = MyEncoder.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.ASCII, MyEncoder.GetBytes(sSourceString))

Try

' Delete the file if it already exists
If fFile.Exists(sFilename) Then
fFile.SetAttributes(sFilename, IO.FileAttributes.Normal)
fFile.Delete(sFilename)
End If

' Output the bytes
fStream = fFile.OpenWrite(sFilename)
fStream.Write(ANSIString, 0, ANSIString.Length)
fStream.Close()

Catch myException As Exception
' Show a message box if an error occurs
MessageBox.Show(myException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
xshhui 2003-11-21
  • 打赏
  • 举报
回复
up
kimurakenshin 2003-11-21
  • 打赏
  • 举报
回复
帮你UP UP UP......
  • 打赏
  • 举报
回复
我也 up
rainstormmaster 2003-11-21
  • 打赏
  • 举报
回复
可以根据utf-8编码规则自己写函数,关于编码规则可参考:
http://www.linuxforum.net/books/UTF-8-Unicode.html
luzufu 2003-11-21
  • 打赏
  • 举报
回复
好象不难啊,你可以引用xml4.0的阿!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧