cURL / Mailing Lists / curl-library / Single Mail

curl-library

Retrieving text from a Windows server as a Mac format file?

From: Armando Miguel Cerasoli Quintero <olio_el_golpe_seco_at_hotmail.com>
Date: Thu, 19 May 2011 20:44:45 +0000

Hi there...
So... I'm trying to retrieve my "scores" file from the server, but I'm getting an extra "Carriage return" sequence.
I'm saving again the file on my PC using a normal ofstream to check it.
Notepad says it's a Macintosh file... But I think there is something wrong when I manipulate the data...
This is the original file:http://static.allegro.cc/image/cache/1/e/1ef0830867344a0a80c637f48e0073fd.pngThis is what I get:http://static.allegro.cc/image/cache/3/4/3499110885de8bed2e8a47563f8f4038.pngand then when I show it on my game:http://static.allegro.cc/image/cache/4/b/4bd46a7e411bb8787bd04c8878074d71.png
This is what I'm doing:
  void tabla_tiempos(ALLEGRO_USTR *array[15]){
     CURL *curl; CURLcode res; curl = curl_easy_init();
     std::string string;
     if(curl){
        curl_easy_setopt(curl, CURLOPT_URL, "http://www.myweb.com/script.php"); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=lllñññ&project=curl"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); ///Here I'm calling the Function write_data. curl_easy_setopt(curl, CURLOPT_WRITEDATA, &string);
        res = curl_easy_perform(curl); curl_easy_cleanup(curl);
     }

  }
  static size_t write_data(void *buffer/*The data*/, size_t size, size_t nmemb, std::string *userp){
     size_t n = size * nmemb; userp->append((char *)buffer, n);
     std::ofstream outfile ("check_it.txt"); outfile.write ((char *)buffer, 50); outfile.close();
     return n;
  }

And this is what the game shows:
I don't know in which step I'm adding that extra CR
And the PHP script:

<?php$myFile = "scores";$fh = fopen($myFile, 'r');$theData = fread($fh, filesize($myFile));fclose($fh);echo $theData;?>

Thank in advance...

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-19