Replacing char

Discussion in 'ASP .Net' started by anonymous, Nov 10, 2004.

  1. anonymous

    anonymous Guest

    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 ?
    anonymous, Nov 10, 2004
    #1
    1. Advertising

  2. 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:

    > 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 ?
    >
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #2
    1. Advertising

  3. anonymous

    anonymous Guest

    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.

    >-----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:
    >
    >> 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 ?
    >>

    >.
    >
    anonymous, Nov 10, 2004
    #3
  4. anonymous

    mortb Guest

    I don't see any Âs in the feed? Is it really the character you want to
    replace?
    cheers,
    mortb

    "anonymous" <> wrote in message
    news:464401c4c6e1$27ad5a30$...
    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.

    >-----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:
    >
    >> 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, Nov 10, 2004
    #4
  5. anonymous

    anonymous Guest

    Try my code and you will see that the asp page contains
    this character.




    >-----Original Message-----
    >I don't see any Âs in the feed? Is it really the

    character you want to
    >replace?
    >cheers,
    >mortb
    >
    >"anonymous" <> wrote

    in message
    >news:464401c4c6e1$27ad5a30$...
    >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.
    >
    >>-----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:
    >>
    >>> 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 ?
    >>>

    >>.
    >>

    >
    >
    >.
    >
    anonymous, Nov 10, 2004
    #5
  6. I get exceptions when I run your code ("could not find a part of the path"),
    but tracing through still don't see the  (e.g. strPost.IndexOf("Â") fails).
    Is it possible you have a code page problem?

    Bill

    "anonymous" wrote:

    > Try my code and you will see that the asp page contains
    > this character.
    >
    >
    >
    >
    > >-----Original Message-----
    > >I don't see any Âs in the feed? Is it really the

    > character you want to
    > >replace?
    > >cheers,
    > >mortb
    > >
    > >"anonymous" <> wrote

    > in message
    > >news:464401c4c6e1$27ad5a30$...
    > >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.
    > >
    > >>-----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:
    > >>
    > >>> 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 ?
    > >>>
    > >>.
    > >>

    > >
    > >
    > >.
    > >

    >
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #6
  7. anonymous

    Anonymous Guest

    The A character only appear in the created file. Ofcourse
    you need the change the path so that it works on your
    system.

    Please help.



    >-----Original Message-----
    >I get exceptions when I run your code ("could not find a

    part of the path"),
    >but tracing through still don't see the Ã, (e.g.

    strPost.IndexOf("Ã,") fails).
    >Is it possible you have a code page problem?
    >
    >Bill
    >
    >"anonymous" wrote:
    >
    >> Try my code and you will see that the asp page contains
    >> this character.
    >>
    >>
    >>
    >>
    >> >-----Original Message-----
    >> >I don't see any Ã,s in the feed? Is it really the

    >> character you want to
    >> >replace?
    >> >cheers,
    >> >mortb
    >> >
    >> >"anonymous" <>

    wrote
    >> in message
    >> >news:464401c4c6e1$27ad5a30$...
    >> >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.
    >> >
    >> >>-----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("Ãf,", "")?
    >> >>
    >> >>Bill
    >> >>
    >> >>"anonymous" wrote:
    >> >>
    >> >>> Hello,
    >> >>>
    >> >>> I need to replace this char Ãf, 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 ?
    >> >>>
    >> >>.
    >> >>
    >> >
    >> >
    >> >.
    >> >

    >>

    >.
    >
    Anonymous, Nov 10, 2004
    #7
  8. My dumb mistake on the path. Looks like the source has some nonbreaking
    spaces ( ascii 160), which the htmldecode is turning into asc 194. I'm
    guessing you could do your replace *after* the decode, else replace on 160
    *before* the decode. As to why that space is not encoded, whereas, say, the
    <'s are correctly converted to < etc., I don't know. Not sure if that happens
    on the rss end, or maybe in your textreader. Anyway, I'm not familiar with
    grabbing a feed the way you're doing it, so can't offer much more. Hopefully
    this will get you going.

    Bill

    "Anonymous" wrote:

    > The A character only appear in the created file. Ofcourse
    > you need the change the path so that it works on your
    > system.
    >
    > Please help.
    >
    >
    >
    > >-----Original Message-----
    > >I get exceptions when I run your code ("could not find a

    > part of the path"),
    > >but tracing through still don't see the Ã, (e.g.

    > strPost.IndexOf("Ã,") fails).
    > >Is it possible you have a code page problem?
    > >
    > >Bill
    > >
    > >"anonymous" wrote:
    > >
    > >> Try my code and you will see that the asp page contains
    > >> this character.
    > >>
    > >>
    > >>
    > >>
    > >> >-----Original Message-----
    > >> >I don't see any Ã,s in the feed? Is it really the
    > >> character you want to
    > >> >replace?
    > >> >cheers,
    > >> >mortb
    > >> >
    > >> >"anonymous" <>

    > wrote
    > >> in message
    > >> >news:464401c4c6e1$27ad5a30$...
    > >> >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.
    > >> >
    > >> >>-----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("Ãf,", "")?
    > >> >>
    > >> >>Bill
    > >> >>
    > >> >>"anonymous" wrote:
    > >> >>
    > >> >>> Hello,
    > >> >>>
    > >> >>> I need to replace this char Ãf, 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 ?
    > >> >>>
    > >> >>.
    > >> >>
    > >> >
    > >> >
    > >> >.
    > >> >
    > >>

    > >.
    > >

    >
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #8
  9. anonymous

    Anonymous Guest

    Thanks man. That did the trick. I was replacing 194 before
    encoding. Now I am replacing 160 before encoding and it
    works like a charm. How did you know that it 160 before
    encoding?

    Thanks


    >-----Original Message-----
    >My dumb mistake on the path. Looks like the source has

    some nonbreaking
    >spaces ( ascii 160), which the htmldecode is turning

    into asc 194. I'm
    >guessing you could do your replace *after* the decode,

    else replace on 160
    >*before* the decode. As to why that space is not encoded,

    whereas, say, the
    ><'s are correctly converted to < etc., I don't know. Not

    sure if that happens
    >on the rss end, or maybe in your textreader. Anyway, I'm

    not familiar with
    >grabbing a feed the way you're doing it, so can't offer

    much more. Hopefully
    >this will get you going.
    >
    >Bill
    >
    >"Anonymous" wrote:
    >
    >> The A character only appear in the created file.

    Ofcourse
    >> you need the change the path so that it works on your
    >> system.
    >>
    >> Please help.
    >>
    >>
    >>
    >> >-----Original Message-----
    >> >I get exceptions when I run your code ("could not find

    a
    >> part of the path"),
    >> >but tracing through still don't see the Ãf, (e.g.

    >> strPost.IndexOf("Ãf,") fails).
    >> >Is it possible you have a code page problem?
    >> >
    >> >Bill
    >> >
    >> >"anonymous" wrote:
    >> >
    >> >> Try my code and you will see that the asp page

    contains
    >> >> this character.
    >> >>
    >> >>
    >> >>
    >> >>
    >> >> >-----Original Message-----
    >> >> >I don't see any Ãf,s in the feed? Is it really the
    >> >> character you want to
    >> >> >replace?
    >> >> >cheers,
    >> >> >mortb
    >> >> >
    >> >> >"anonymous" <>

    >> wrote
    >> >> in message
    >> >> >news:464401c4c6e1$27ad5a30$...
    >> >> >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("Ãf,", "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.
    >> >> >
    >> >> >>-----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("Ãff,", "")?
    >> >> >>
    >> >> >>Bill
    >> >> >>
    >> >> >>"anonymous" wrote:
    >> >> >>
    >> >> >>> Hello,
    >> >> >>>
    >> >> >>> I need to replace this char Ãff, 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 ?
    >> >> >>>
    >> >> >>.
    >> >> >>
    >> >> >
    >> >> >
    >> >> >.
    >> >> >
    >> >>
    >> >.
    >> >

    >>

    >.
    >
    Anonymous, Nov 10, 2004
    #9
  10. P.S. There's a good article here you might find interesting:

    http://aspnet.4guysfromrolla.com/articles/031903-1.aspx

    "Anonymous" wrote:

    > The A character only appear in the created file. Ofcourse
    > you need the change the path so that it works on your
    > system.
    >
    > Please help.
    >
    >
    >
    > >-----Original Message-----
    > >I get exceptions when I run your code ("could not find a

    > part of the path"),
    > >but tracing through still don't see the Ã, (e.g.

    > strPost.IndexOf("Ã,") fails).
    > >Is it possible you have a code page problem?
    > >
    > >Bill
    > >
    > >"anonymous" wrote:
    > >
    > >> Try my code and you will see that the asp page contains
    > >> this character.
    > >>
    > >>
    > >>
    > >>
    > >> >-----Original Message-----
    > >> >I don't see any Ã,s in the feed? Is it really the
    > >> character you want to
    > >> >replace?
    > >> >cheers,
    > >> >mortb
    > >> >
    > >> >"anonymous" <>

    > wrote
    > >> in message
    > >> >news:464401c4c6e1$27ad5a30$...
    > >> >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.
    > >> >
    > >> >>-----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("Ãf,", "")?
    > >> >>
    > >> >>Bill
    > >> >>
    > >> >>"anonymous" wrote:
    > >> >>
    > >> >>> Hello,
    > >> >>>
    > >> >>> I need to replace this char Ãf, 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 ?
    > >> >>>
    > >> >>.
    > >> >>
    > >> >
    > >> >
    > >> >.
    > >> >
    > >>

    > >.
    > >

    >
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #10
  11. anonymous

    Anonymous Guest

    Its a regular article about consuming rss. I do it the
    same way. Thanks :)


    >-----Original Message-----
    >P.S. There's a good article here you might find

    interesting:
    >
    >http://aspnet.4guysfromrolla.com/articles/031903-1.aspx
    >
    >"Anonymous" wrote:
    >
    >> The A character only appear in the created file.

    Ofcourse
    >> you need the change the path so that it works on your
    >> system.
    >>
    >> Please help.
    >>
    >>
    >>
    >> >-----Original Message-----
    >> >I get exceptions when I run your code ("could not find

    a
    >> part of the path"),
    >> >but tracing through still don't see the Ãf, (e.g.

    >> strPost.IndexOf("Ãf,") fails).
    >> >Is it possible you have a code page problem?
    >> >
    >> >Bill
    >> >
    >> >"anonymous" wrote:
    >> >
    >> >> Try my code and you will see that the asp page

    contains
    >> >> this character.
    >> >>
    >> >>
    >> >>
    >> >>
    >> >> >-----Original Message-----
    >> >> >I don't see any Ãf,s in the feed? Is it really the
    >> >> character you want to
    >> >> >replace?
    >> >> >cheers,
    >> >> >mortb
    >> >> >
    >> >> >"anonymous" <>

    >> wrote
    >> >> in message
    >> >> >news:464401c4c6e1$27ad5a30$...
    >> >> >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("Ãf,", "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.
    >> >> >
    >> >> >>-----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("Ãff,", "")?
    >> >> >>
    >> >> >>Bill
    >> >> >>
    >> >> >>"anonymous" wrote:
    >> >> >>
    >> >> >>> Hello,
    >> >> >>>
    >> >> >>> I need to replace this char Ãff, 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 ?
    >> >> >>>
    >> >> >>.
    >> >> >>
    >> >> >
    >> >> >
    >> >> >.
    >> >> >
    >> >>
    >> >.
    >> >

    >>

    >.
    >
    Anonymous, Nov 10, 2004
    #11
  12. I just looked at the 194's, then went back to those same positions in the
    original and found the 160's by dumping the ascii values of those strings. I
    had also guessed it might be something with &nbsp's, which is always a decent
    bet when something looks ok on the screen but your code chokes on it. Have
    fun.

    "Anonymous" wrote:

    > Thanks man. That did the trick. I was replacing 194 before
    > encoding. Now I am replacing 160 before encoding and it
    > works like a charm. How did you know that it 160 before
    > encoding?
    >
    > Thanks
    >
    >
    > >-----Original Message-----
    > >My dumb mistake on the path. Looks like the source has

    > some nonbreaking
    > >spaces ( ascii 160), which the htmldecode is turning

    > into asc 194. I'm
    > >guessing you could do your replace *after* the decode,

    > else replace on 160
    > >*before* the decode. As to why that space is not encoded,

    > whereas, say, the
    > ><'s are correctly converted to < etc., I don't know. Not

    > sure if that happens
    > >on the rss end, or maybe in your textreader. Anyway, I'm

    > not familiar with
    > >grabbing a feed the way you're doing it, so can't offer

    > much more. Hopefully
    > >this will get you going.
    > >
    > >Bill
    > >
    > >"Anonymous" wrote:
    > >
    > >> The A character only appear in the created file.

    > Ofcourse
    > >> you need the change the path so that it works on your
    > >> system.
    > >>
    > >> Please help.
    > >>
    > >>
    > >>
    > >> >-----Original Message-----
    > >> >I get exceptions when I run your code ("could not find

    > a
    > >> part of the path"),
    > >> >but tracing through still don't see the Ãf, (e.g.
    > >> strPost.IndexOf("Ãf,") fails).
    > >> >Is it possible you have a code page problem?
    > >> >
    > >> >Bill
    > >> >
    > >> >"anonymous" wrote:
    > >> >
    > >> >> Try my code and you will see that the asp page

    > contains
    > >> >> this character.
    > >> >>
    > >> >>
    > >> >>
    > >> >>
    > >> >> >-----Original Message-----
    > >> >> >I don't see any Ãf,s in the feed? Is it really the
    > >> >> character you want to
    > >> >> >replace?
    > >> >> >cheers,
    > >> >> >mortb
    > >> >> >
    > >> >> >"anonymous" <>
    > >> wrote
    > >> >> in message
    > >> >> >news:464401c4c6e1$27ad5a30$...
    > >> >> >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("Ãf,", "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.
    > >> >> >
    > >> >> >>-----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("Ãff,", "")?
    > >> >> >>
    > >> >> >>Bill
    > >> >> >>
    > >> >> >>"anonymous" wrote:
    > >> >> >>
    > >> >> >>> Hello,
    > >> >> >>>
    > >> >> >>> I need to replace this char Ãff, 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 ?
    > >> >> >>>
    > >> >> >>.
    > >> >> >>
    > >> >> >
    > >> >> >
    > >> >> >.
    > >> >> >
    > >> >>
    > >> >.
    > >> >
    > >>

    > >.
    > >

    >
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #12
  13. Hey, wasn't regular to me--I learned all sorts of new things from your post,
    thanks.

    "Anonymous" wrote:

    > Its a regular article about consuming rss. I do it the
    > same way. Thanks :)
    >
    >
    > >-----Original Message-----
    > >P.S. There's a good article here you might find

    > interesting:
    > >
    > >http://aspnet.4guysfromrolla.com/articles/031903-1.aspx
    > >
    > >"Anonymous" wrote:
    > >
    > >> The A character only appear in the created file.

    > Ofcourse
    > >> you need the change the path so that it works on your
    > >> system.
    > >>
    > >> Please help.
    > >>
    > >>
    > >>
    > >> >-----Original Message-----
    > >> >I get exceptions when I run your code ("could not find

    > a
    > >> part of the path"),
    > >> >but tracing through still don't see the Ãf, (e.g.
    > >> strPost.IndexOf("Ãf,") fails).
    > >> >Is it possible you have a code page problem?
    > >> >
    > >> >Bill
    > >> >
    > >> >"anonymous" wrote:
    > >> >
    > >> >> Try my code and you will see that the asp page

    > contains
    > >> >> this character.
    > >> >>
    > >> >>
    > >> >>
    > >> >>
    > >> >> >-----Original Message-----
    > >> >> >I don't see any Ãf,s in the feed? Is it really the
    > >> >> character you want to
    > >> >> >replace?
    > >> >> >cheers,
    > >> >> >mortb
    > >> >> >
    > >> >> >"anonymous" <>
    > >> wrote
    > >> >> in message
    > >> >> >news:464401c4c6e1$27ad5a30$...
    > >> >> >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("Ãf,", "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.
    > >> >> >
    > >> >> >>-----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("Ãff,", "")?
    > >> >> >>
    > >> >> >>Bill
    > >> >> >>
    > >> >> >>"anonymous" wrote:
    > >> >> >>
    > >> >> >>> Hello,
    > >> >> >>>
    > >> >> >>> I need to replace this char Ãff, 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 ?
    > >> >> >>>
    > >> >> >>.
    > >> >> >>
    > >> >> >
    > >> >> >
    > >> >> >.
    > >> >> >
    > >> >>
    > >> >.
    > >> >
    > >>

    > >.
    > >

    >
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wwj
    Replies:
    7
    Views:
    542
  2. wwj
    Replies:
    24
    Views:
    2,484
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    462
    Tristan Miller
    Jan 17, 2004
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,015
    Ian Collins
    May 9, 2006
  5. Rob Meade

    Replacing - and not Replacing...

    Rob Meade, Apr 5, 2005, in forum: ASP General
    Replies:
    5
    Views:
    261
    Chris Hohmann
    Apr 11, 2005
Loading...

Share This Page