替换char [英] Replacing char
本文介绍了替换char的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我需要更换这个字符吗?与另一个char。
但是我无法解决这个问题。我尝试了这个,但是它没有工作:
str = str.Replace(chr(asc(194)),"")
有人可以提供帮助吗?
Hello,
I need to replace this char ? with another char.
However I am not able to acieve this. I tried this but it
doesnt work:
str = str.Replace(chr(asc(194)), "")
Can somebody help ?
推荐答案
替换需要两个字符或两个字符串。在你的情况下,试试:
Dim c As Char = Chr(194)
str = str.Replace(c.ToString,"")
或者为什么不只是str.replace(" ??","")?
Bill
anonymous写道:
The "replace" needs either two characters or two strings. In your case, try:
Dim c As Char = Chr(194)
str = str.Replace(c.ToString, "")
Or why not just str.replace("??", "")?
Bill
"anonymous" wrote:
你好,
我需要更换这个字符?与另一个char。
然而我无法解决这个问题。我尝试了这个,但它没有用:
str = str.Replace(chr(asc(194)),"
有人可以帮忙?
Hello,
I need to replace this char ?? with another char.
However I am not able to acieve this. I tried this but it
doesnt work:
str = str.Replace(chr(asc(194)), "")
Can somebody help ?
我尝试了两个版本,但它仍然无法正常工作。
是我正在阅读以下RSS
( http://pluralsight.com/blogs/dbox/Rss.aspx )并使用项目描述创建
文件。文件
仅包含带有奇怪字符的描述。这里
是我的完整代码:
Dim reader As New XmlTextReader
(" http://pluralsight.com/ blogs / dbox / Rss.aspx")
Dim xmlDoc As New XmlDocument
xmlDoc.Load(读者)
Dim nodes As XmlNodeList = xmlDoc.SelectNodes
(" / rss / channel / item")
dim i as integer = 0
>
For Each node As XmlNode In节点
尝试
strPost = node(" description")。InnerXml
Dim c as char = Chr(194)
strPost = strPost.Replace("?"," XX")
Dim fp As StreamWriter
dim strfile as string = Server.MapPath(" xml_news //")
strfile = strfile& i.tostring()
strfile = strfile& " .asp"
fp = File.CreateText(strfile)
fp.WriteLine("< p>"& Server.HtmlDecode(strPost)
&"< / p>")
fp.close()
Catch ex As Exception
Response.Write(ex.Message()&"< br>")
结束尝试
i = i + 1
下一页
感谢您的帮助。
I tried both versions, but it still doesnt work. The thing
is that I am reading the following rss
(http://pluralsight.com/blogs/dbox/Rss.aspx) and creating
the file with the description of the item. The file
contains only the description with the strange chars. Here
is my complete code:
Dim reader As New XmlTextReader
("http://pluralsight.com/blogs/dbox/Rss.aspx")
Dim xmlDoc As New XmlDocument
xmlDoc.Load(reader)
Dim nodes As XmlNodeList = xmlDoc.SelectNodes
("/rss/channel/item")
dim i as integer = 0
For Each node As XmlNode In nodes
Try
strPost = node("description").InnerXml
Dim c as char = Chr(194)
strPost = strPost.Replace("?", "XX")
Dim fp As StreamWriter
dim strfile as string = Server.MapPath("xml_news//")
strfile = strfile & i.tostring()
strfile = strfile & ".asp"
fp = File.CreateText(strfile)
fp.WriteLine("<p>" & Server.HtmlDecode(strPost)
& "</p>")
fp.close()
Catch ex As Exception
Response.Write(ex.Message() & "<br>")
End Try
i = i + 1
Next
Thanks for any help.
-----原始消息-----
;替换"需要两个字符或两个字符串。
在你的情况下,试试:
Dim c As Char = Chr(194)
str = str.Replace(c.ToString,"")
或者为什么不只是str.replace(?,,")?
比尔
匿名写道:
-----Original Message-----
The "replace" needs either two characters or two strings. In your case, try:
Dim c As Char = Chr(194)
str = str.Replace(c.ToString, "")
Or why not just str.replace("?,", "")?
Bill
"anonymous" wrote:
你好,
我需要用另一个char替换这个char?
但是我无法解决这个问题。我试过这个,但
它不起作用:
str = str.Replace(chr(asc(194)),"
有人可以帮忙?
Hello,
I need to replace this char ?, with another char.
However I am not able to acieve this. I tried this but it doesnt work:
str = str.Replace(chr(asc(194)), "")
Can somebody help ?
。
我在饲料中看不到任何东西?它真的是你想要的角色吗?
替换?
欢呼,
mortb
" ;匿名" <一个******* @ discussions.microsoft.com>在消息中写道
news:46 **************************** @ phx.gbl ...
我试过两个版本,但它仍然无法正常工作。
是我正在阅读以下RSS
( http://pluralsight.com/blogs/dbox/Rss.aspx )并使用项目描述创建
文件。文件
仅包含带有奇怪字符的描述。这里
是我的完整代码:
Dim reader As New XmlTextReader
(" http://pluralsight.com/ blogs / dbox / Rss.aspx")
Dim xmlDoc As New XmlDocument
xmlDoc.Load(读者)
Dim nodes As XmlNodeList = xmlDoc.SelectNodes
(" / rss / channel / item")
dim i as integer = 0
>
For Each node As XmlNode In节点
尝试
strPost = node(" description")。InnerXml
Dim c as char = Chr(194)
strPost = strPost.Replace("?"," XX")
Dim fp As StreamWriter
dim strfile as string = Server.MapPath(" xml_news //")
strfile = strfile& i.tostring()
strfile = strfile& " .asp"
fp = File.CreateText(strfile)
fp.WriteLine("< p>"& Server.HtmlDecode(strPost)
&"< / p>")
fp.close()
Catch ex As Exception
Response.Write(ex.Message()&"< br>")
结束尝试
i = i + 1
下一页
感谢您的帮助。
I don''t see any ?s in the feed? Is it really the character you want to
replace?
cheers,
mortb
"anonymous" <an*******@discussions.microsoft.com> wrote in message
news:46****************************@phx.gbl...
I tried both versions, but it still doesnt work. The thing
is that I am reading the following rss
(http://pluralsight.com/blogs/dbox/Rss.aspx) and creating
the file with the description of the item. The file
contains only the description with the strange chars. Here
is my complete code:
Dim reader As New XmlTextReader
("http://pluralsight.com/blogs/dbox/Rss.aspx")
Dim xmlDoc As New XmlDocument
xmlDoc.Load(reader)
Dim nodes As XmlNodeList = xmlDoc.SelectNodes
("/rss/channel/item")
dim i as integer = 0
For Each node As XmlNode In nodes
Try
strPost = node("description").InnerXml
Dim c as char = Chr(194)
strPost = strPost.Replace("?", "XX")
Dim fp As StreamWriter
dim strfile as string = Server.MapPath("xml_news//")
strfile = strfile & i.tostring()
strfile = strfile & ".asp"
fp = File.CreateText(strfile)
fp.WriteLine("<p>" & Server.HtmlDecode(strPost)
& "</p>")
fp.close()
Catch ex As Exception
Response.Write(ex.Message() & "<br>")
End Try
i = i + 1
Next
Thanks for any help.
-----原始消息-----
;替换"需要两个字符或两个字符串。
在你的情况下,试试:
Dim c As Char = Chr(194)
str = str.Replace(c.ToString,"")
或者为什么不只是str.replace(?,,")?
比尔
匿名写道:
-----Original Message-----
The "replace" needs either two characters or two strings. In your case, try:
Dim c As Char = Chr(194)
str = str.Replace(c.ToString, "")
Or why not just str.replace("?,", "")?
Bill
"anonymous" wrote:
你好,
我需要用另一个字符替换这个char?
但是我无法解决这个问题。我试过这个,但
它不起作用:
str = str.Replace(chr(asc(194)),"
有人可以帮忙?
Hello,
I need to replace this char ?, with another char.
However I am not able to acieve this. I tried this but it doesnt work:
str = str.Replace(chr(asc(194)), "")
Can somebody help ?
。
这篇关于替换char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文