SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Degree symbol in string to Flickr

    Hi

    Small quick question. I'm sending a string and image from a php script to flickr via phpflickr. My string (which is for the image title in Flickr - plain text) has a degree symbol in it () which is displaying in Flickr as an upsidedown exclamation mark. I've tried using the degree symbol entity which definetly doesn't work so the title in Flickr is plain text but if I manually edit the title in Flickr and insert the degree symbol it displays fine.

    What's happening in transit? Backslashing the sybol doesn't help.

    Thanks in advance.
    Garrett

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    This sounds as if it is an encoding problem at your end. The flickr xml stream is encoded utf-8 so you either need to stick with that encoding stream everywhere or try and change it the encoding scheme you are already using. This is no small task though, you have to have files, database, database communication, browser settings, html settings all set to utf-8

    To prove this either way the first thing is to establish what encoding your pages currently have, your browser may tell you.

  3. #3
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi

    My page is now utf-8 as I've added a header to it. That changed the output on the page but it's still arriving at Flickr without the degree symbol. Also tried utf8_encode() which didn't seem to do anything.

    >you have to have files, database, database communication, browser settings, html settings all set to utf-8

    my page is an bridge from Layar to Flickr, normally it won't be loaded in a browser (but I am testing that way for speed at the moment) and there are no databases used.

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Sorry, I did not read your OP correctly, you are experiencing problems sending data to Flickr...

    Well that expects to be given utf-8 only, maybe it is not utf-8 coming from Layar? Though seemingly Flickr can handle iso-8859-1.

    Grab the data from Layar and in a decent IDE see what encoding that has by default, maybe?

  5. #5
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >Grab the data from Layar and in a decent IDE see what encoding that has by default, maybe?

    Not sure how I could do that, the data from Layar is sent as a http post which looks like this:

    ------------ThIs_Is_tHe_bouNdaRY_$
    Content-Disposition: form-data; name="message"
    This screenshot was taken with the Layar Reality Browser!
    ------------ThIs_Is_tHe_bouNdaRY_$
    Content-Disposition: form-data; name="screenshot"; filename="filename.jpg"
    Content-Type: image/jpeg
    <binary screenshot data>------------ThIs_Is_tHe_bouNdaRY_$--

    can't it just be converted? I'm looking at mb_convert_encoding($str, "UTF-8") now, will this help?

  6. #6
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mb_convert_encoding($str, "UTF-8") makes the degree symbol disapear Flickr side. I've had a look at the curl post in phpflickr now as well and it doesn't seem to send with any encoding. If I add:

    curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8');

    it doesn't change and if I add:

    $headers = array("Content-type: text/html; charset=utf-8");
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

    the durl post fails.

    So much for a "small quick question".

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    ... that's if encoding is the problem of course. Maybe it is something else.

  8. #8
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not convinced it is encoding. I've stripped all the Layar stuff out now and faked the details as plain strings, the issue is still there when it arrives at Flickr so Layar isn't the issue. It may be phpflickr is sending the data incorrectly but as soon as encoding was mentioned I searched about encoding and flickr and as plain as day the first thing that comes up is "The Flickr API expects all data to be UTF-8 encoded." so I think it's unlikely that the phpflickr developers would have overlooked that.

    Anyway I've swapped things around now to just display the degree symbol in the description (entities work there fine) because this was taking too much time for a small detail. If anyone else has a suggestion of what might be the issue with the degree symbol in the flickr image title I's appreciate it as it's annoying me but otherwise I'll just use as is.

    thanks for your help
    Garrett

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    How annoying.

    The only thing I can think of is to create a utf-8 file from scratch in your IDE, and use that as a test -- but it sounds as if that is what you tried.

    Sorry not to be of any more help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •