UrlEncode French characters - wrong encoding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John C.

    UrlEncode French characters - wrong encoding

    Hi, I've tried using System.Web.Http Utility.UrlEnco de("é") with each
    of the possible encodings ASCII, Unicode, UTF7, UTF8 but none of these
    gives what I want: %e9. And so on for the other French characters. Am I
    missing something here?

  • Martin Honnen

    #2
    Re: UrlEncode French characters - wrong encoding



    John C. wrote:
    [color=blue]
    > Hi, I've tried using System.Web.Http Utility.UrlEnco de("é") with each
    > of the possible encodings ASCII, Unicode, UTF7, UTF8 but none of these
    > gives what I want: %e9. And so on for the other French characters. Am I
    > missing something here?[/color]

    Use ISO-8859-1 as the encoding name. Or Windows-1252. e.g.
    HttpUtility.Url Encode("é",
    System.Text.Enc oding.GetEncodi ng("ISO-8859-1"))


    --

    Martin Honnen --- MVP XML

    Comment

    • Joerg Jooss

      #3
      Re: UrlEncode French characters - wrong encoding

      Thus wrote John C.,
      [color=blue]
      > Hi, I've tried using System.Web.Http Utility.UrlEnco de("é") with each
      > of the possible encodings ASCII, Unicode, UTF7, UTF8 but none of these
      > gives what I want: %e9. And so on for the other French characters. Am
      > I missing something here?[/color]

      Yes, the correct encoding ;-)

      ISO-8859-15 or Windows-1252 is the encoding you're probably looking for:

      Encoding latin9 = Encoding.GetEnc oding("iso-8859-15");
      string encodedUrl = HttpUtility.Url Encode(url, latin9);

      Cheers,
      --
      Joerg Jooss
      news-reply@joergjoos s.de


      Comment

      • Joerg Jooss

        #4
        Re: UrlEncode French characters - wrong encoding

        Thus wrote Martin,
        [color=blue]
        > Use ISO-8859-1 as the encoding name. Or Windows-1252. e.g.
        > HttpUtility.Url Encode("é",
        > System.Text.Enc oding.GetEncodi ng("ISO-8859-1"))[/color]

        Some fun encoding trivia: There are two french glyphs that don't exist in
        ISO-8859-1: The uppercase and lowercase "oe" ligature (Unicode \u0152 and
        \u0153). That's why I've proposed Latin 9 instead in my other post. If it's
        all about "é", Latin 1 is OK :-)

        Cheers,
        --
        Joerg Jooss
        news-reply@joergjoos s.de


        Comment

        • Laurent Bugnion

          #5
          Re: UrlEncode French characters - wrong encoding

          Off topic ;-)

          Martin Honnen wrote:

          Martin, you're the Martin Honnen who was (and maybe still is, I lost
          contact lately) on comp.lang.javas cript, I suppose. Nice to see you here
          too.

          Friendly greetings,
          Laurent
          --
          Laurent Bugnion, GalaSoft
          Software engineering: http://www.galasoft-LB.ch
          Private/Malaysia: http://mypage.bluewin.ch/lbugnion
          Support children in Calcutta: http://www.calcutta-espoir.ch

          Comment

          • John C.

            #6
            Re: UrlEncode French characters - wrong encoding

            Thank you so much to everyone who replied. That fixed my problem right
            away!

            Comment

            Working...