0
$\begingroup$

I have retrieved a file from a web server by means of the FetchURLWithHeaders function.

The retun value from FetchURLWithHeaders should contains the substring

SCHØNHEYDER

but instead I find

SCH����NHEYDER

and

ToCharacterCode /@ Characters["SCH����NHEYDER"]

gives

{{83}, {67}, {72}, {65533}, {65533}, {65533}, {65533}, {78}, {72}, {69}, {89}, {68}, {69}, {82}}

How can I transform SCH����NHEYDER in SCHØNHEYDER and print in a text file ?

Thanks a lot !!

$\endgroup$
  • $\begingroup$ Utilities`URLTools`FetchURLWithHeaders is an older, undocumented function. Have you tried URLFetch instead? The "SCH����NHEYDER" string can not be turn into the original as the � character (65533) is used to replace an incoming character whose value is unknown or unrepresentable in Unicode. So, the original value is lost. $\endgroup$ – Sjoerd C. de Vries Jan 27 '15 at 22:04
  • 2
    $\begingroup$ You could try URLFetch with the option "Headers" -> {"Content-Type" -> "text/html;charset=utf-8"}. Could you provide an example URL to test with? $\endgroup$ – Sjoerd C. de Vries Jan 27 '15 at 22:13
  • $\begingroup$ I have Mathematica 8.0.0.1; I can count only on the versions of functions provided there. -1- I get: FetchURL // Options {FileFilters -> {{".gz", UncompressGZIPFile}}, "ServerAuthentication" -> Automatic, "Timeout" -> Automatic, "RequestMethod" -> "GET", "RequestParameters" -> {}, "RequestHeaderFields" -> {}} FetchURLWithHeaders // Options {} -2- FetchURLWithHeaders accepts option "Headers" but return value is unchanged. -3- FetchURLWithHeaders calls FetchURLInternal. Can I make FetchURLInternal public by means of FetchURLInternal::usage="something" and adapt it ? $\endgroup$ – mitochondrial Jan 28 '15 at 8:51
  • $\begingroup$ If you're targeting a specific version you should mention that in the question. Anyway, could you try FetchURL with its option "RequestHeaderFields" set to the value mentioned above for "Headers"? Also, still waiting for an example URL. $\endgroup$ – Sjoerd C. de Vries Jan 28 '15 at 10:27
  • $\begingroup$ In an earlier question you mention using version 9. How come you're using v8 now? $\endgroup$ – Sjoerd C. de Vries Jan 28 '15 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.