# how can I manage the characters encoding of retun value from FetchURLWithHeaders?

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 !!

• UtilitiesURLToolsFetchURLWithHeaders 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. – Sjoerd C. de Vries Jan 27 '15 at 22:04
• You could try URLFetch with the option "Headers" -> {"Content-Type" -> "text/html;charset=utf-8"}. Could you provide an example URL to test with? – Sjoerd C. de Vries Jan 27 '15 at 22:13
• 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 ? – mitochondrial Jan 28 '15 at 8:51
• 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. – Sjoerd C. de Vries Jan 28 '15 at 10:27
• In an earlier question you mention using version 9. How come you're using v8 now? – Sjoerd C. de Vries Jan 28 '15 at 10:32