Skip to content
Tcl Source Code History Of Ticket 839289ffffffffff
Login

History Of Ticket 839289ffffffffff

Artifacts Associated With Ticket 839289ffffffffff

  1. Ticket change [55660f7b5e] (rid 94124) by vincentdarley on 2003-11-10 16:00:39:

    1. assignee initialized to: "hobbs"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Many web pages (incl. Tcl'ers Wiki) place charset
      information in metatags, like this:
      
      <html>
      <head>
      <meta http-equiv="Content-type" content="text/html;
      charset=utf-8"></meta>
      <title>Graffiti</title>
      
      But the http package ignores these and assumes the text
      is in iso8859-1.  This means that non-ascii characters
      are mangled with something as simple as:
      
      set token [http::geturl
      http://alphatcl.sourceforge.net/wikit/10]
      set contents [http::data $token]
      
      '$contents' should now contain a spanish n~ and an
      o-umlaut.  It actually contains garbage for both instead:
      
      spanish ene: ñ</p><p>o-umlaut: ö
      
      
      
    4. foundin initialized to: "obsolete: 8.4.5"
    5. priority initialized to: "7 High"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "vincentdarley"
    9. subsystem initialized to: "29. http Package"
    10. title initialized to: "http ignores charset in meta tags"
    11. type initialized to: "Bug"
  2. Ticket change [2916712b8e] (rid 88813) by dgp on 2003-11-10 23:56:26:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      Isn't this issue something to be
      taken care of by the application,
      and not the http package?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  3. Ticket change [cacb207b7e] (rid 95423) by vincentdarley on 2003-11-11 01:04:20:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      I think it may be too late by the time an application sees
      the data.  The data is in utf8 and has been interpreted as
      iso8859-1 and then possibly dumped down a channel.  It's not
      clear to me that is a non-destructive/reversible operation.
      
      In any case, the http package is documented to handle
      charsets and convert to utf-8.  I quote:
      
      "charset 
      The value of the charset attribute from the Content-Type
      meta-data value. If none was specified, this defaults to the
      RFC standard iso8859-1, or the value of
      $::http::defaultCharset. Incoming text data will be
      automatically converted from this charset to utf-8. "
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  4. Ticket change [2fb0a348a8] (rid 93105) by dgp on 2003-11-11 01:16:57:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      Perhaps an application that
      wants to support http-equiv
      meta tags in HTML content
      will need to use the -binary
      and -progress options
      of [geturl] then?
      
      The documented handling of
      charset refers to the HTTP
      header, AIUI, not to any special
      directive embedded in the content.
      Keep in mind that many kinds of
      content can be transferred using
      the HTTP protocol, not just HTML.
      It seems incorrect to me to put
      HTML-specific handling into the
      http package.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [41e5ee077c] (rid 116274) by vincentdarley on 2003-11-11 01:34:52:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      You may well be right (my knowledge/understanding of what
      ought to be correct here is certainly lacking!), but it
      doesn't seem a bit against the spirit of Tcl to have to go
      through all that hassle.
      
      If we add '-binary', this also means we are explicitly
      disabling the documented charset conversion the package does
      via http headers! This would mean an application would
      actually need to check both the http headers and the
      embedded http-equiv stuff!  Possible, but a bit messy, really.
      
      
      
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  6. Ticket change [a08cf65491] (rid 96832) by dkf on 2003-11-11 02:38:39:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      All is not lost. Try this:
      encoding convertfrom identity \
              {{spanish ene: ñ</p><p>o-umlaut: ö}}
      
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [209d8d7c70] (rid 130455) by hobbs on 2003-11-11 04:19:50:

    1. closedate changed to: "2003-11-10T21:19:50"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      The http package handles the charset parameter correct 
      when it is in the headers.  The stuff in the doc itself is left up 
      to the user, and the correct options will handle it right.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. resolution changed to: "Wont Fix"
    7. status changed to: "Pending"
    8. username: "hobbs"
  8. Ticket change [145b33b62a] (rid 124383) by vincentdarley on 2003-11-11 15:39:30:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      Jeff, what do you mean by 'the correct options will handle it right'?  I 
      understand now that I was expecting too much from http::geturl, but 
      now it's not clear how to get what I want.
      
      In the above example,
      
      upvar #0 $token state
      puts $state(charset)
      
      gives iso8859-1 (the default) which I suppose I must ignore. However, 
      I also suppose it means the text has been read as iso8859-1 (which 
      could surely cause some irretrievable loss, at least where the true 
      encoding is something more complex than utf-8).
      
      Anyway, I see three approaches:
      
      (i) take the returned text, scan it for <head><meta> etc, extra the 
      charset and convert it (but from what? -- the information in $contents 
      is utf-8 which has been read as iso8859-1!!)
      
      (ii) always use -binary 1 with http::geturl and then manually examine 
      both the headers and (when those headers indicate a text file) convert 
      the text as appropriate
      
      (iii) use a normal http::geturl, but with a callback which looks for <
      head><meta> and charset tags in the case where the info is textual, 
      and in that case adjusts the encoding of the channel on the fly 
      (presumably would need to adjust the encoding of the both the input 
      socket and the output channel).
      
      Any advice on how this should work? 
      
      What most concerns me is the aspect of information loss in (i) if the 
      original text is in an encoding which gets munged if its bytes are 
      interpreted as iso8859-1.
      
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "vincentdarley"
  9. Ticket change [3aadbf11f8] (rid 112599) by dkf on 2003-11-12 01:30:45:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      ISO8859-1 is a single byte encoding that gives a meaning to
      every byte, so you've not lost any information *provided*
      you can figure out how to un-mess-up the encodings (there is
      a bijective - and hence invertible - mapping between
      incoming bytes and characters in the string you get out of
      the [http::data].)  The first thing to do is to go from the
      UTF-8 rep of the 8859-1-encoded data so you end up with a
      byte-sequence again.  Once you've done that, you can then
      convert from the byte sequence to the real encoding.  This
      should work fine for most encodings which map the printable
      ASCII subset in similar ways to 8859-1 (i.e. so that you can
      work out what the <META> tag says!) but there are outliers
      (EBCDIC), but in that case you've got an intractable problem
      that should probably be reported to the maintainer of the
      website...
      
      IMHO, putting encoding info inside a <META> tag is broken by
      design anyway since there's no way to bound the amount of
      arbitrarily-encoded information read from the HTTP
      connection before the encoding switch happens.  XML does a
      more sensible job of this bit at least.
      
      (Understanding <META> is a job for an HTML parser, which the
      HTTP package isn't.  You might want to check whether the
      HTML parser in tcllib does the right thing though...)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  10. Ticket change [86f186a422] (rid 131605) by hobbs on 2003-11-12 01:43:35:

    1. closedate changed to: "2003-11-11T18:43:35"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      The other option is to use -binary, which will ensure no 
      encoding translation is done until you do it, which is OK since 
      all the charset stuff you want is defined in ASCII-7, which will 
      be easy to find.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "hobbs"