FAQ |
Kalender |
![]() |
#11 | |||
|
||||
Klarade millennium-buggen
|
Citat:
EDIT: Det hjälpte nog inte dig. Hmm... |
|||
![]() |
![]() |
![]() |
#12 | ||
|
|||
Nykomling
|
Testade att hämta Encodingen från min HttpWebResponse, bra förslag förresten. Anyway, det returnerade Unicode (UTF-8), vilket tyvärr inte hjälper mig alls.
Alltså, den innehåller inte felaktiga tecken innan strängen hamnar i StreamReader:n, utan det sker som sagt innuti StreamReader:n. Och jag har ju korrekt Encoding, därför jag frågar om hjälp här. Vet ni nåt mer man kan testa? ;-) |
||
![]() |
![]() |
![]() |
#13 | ||
|
|||
Flitig postare
|
Har du provat med att använda Encoding.Unicode istället för Encoding.UTF8?
/Patrik Berggren |
||
![]() |
![]() |
![]() |
#14 | ||
|
|||
Flitig postare
|
Enklast borde väl vara att ansluta med debuggern och se vad som händer? Testa att byta och köra med lite olika encodings? Någonting lär ju fungera
|
||
![]() |
![]() |
![]() |
#15 | |||
|
||||
Medlem
|
Vet inte riktigt om jag förstår problemet. Detta fungerar hur bra som helst för mig direkt i ett nytt VS projekt.
Kod:
if (!IsPostBack) * * * * * *{ * * * * * * * *string formattedUri = @"http://sv.wikipedia.org/wiki/G%C3%B6ran_Persson"; * * * * * * * *WebRequest webRequest = WebRequest.Create(formattedUri); * * * * * * * *HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); * * * * * * * *string jsonResponse = string.Empty; * * * * * * * *using (StreamReader sr = new StreamReader(response.GetResponseStream())) * * * * * * * *{ * * * * * * * * * *jsonResponse = sr.ReadToEnd(); * * * * * * * * * *Response.Write(jsonResponse); * * * * * * * *} * * * * * *} Kod:
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"sv\" lang=\"sv\" dir=\"ltr\">\n\t<head>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\t\t<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n\t\t<meta name=\"generator\" content=\"MediaWiki 1.15alpha\" />\n\t\t<meta name=\"keywords\" content=\"Göran Persson,Sveriges statsministrar,14 juni,16 mars,17 september,1949,1969,1971,1977,1979,1984\" />\ |
|||
![]() |
![]() |
![]() |
#16 | ||
|
|||
Nykomling
|
Citat:
Kod:
private readonly static string WebServiceURL = @"http://www.dapper.net/transform.php?dappName=Fetchwikipediacontent&transformer=JSON&v_SearchTerm={0}&v_Language={1}"; string formattedUri = String.Format(WebServiceURL, "Göran Hägglund", "EN"); HttpWebRequest webRequest = GetWebRequest(formattedUri); HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); Encoding enc = Encoding.GetEncoding(response.CharacterSet); string jsonResponse = string.Empty; Encoding encoding = Encoding.UTF8; using (StreamReader sr = new StreamReader(response.GetResponseStream(), encoding)) { jsonResponse = sr.ReadToEnd(); } |
||
![]() |
![]() |
![]() |
#17 | |||
|
||||
Medlem
|
Nej den returnerar
Kod:
"{\"error\":\"Something went wrong while the Dapp ran. The error has been logged, and we're looking into it.\"}" |
|||
![]() |
![]() |
![]() |
#18 | ||
|
|||
Banned
|
|||
![]() |
![]() |
![]() |
#19 | ||
|
|||
Nykomling
|
|||
![]() |
![]() |
![]() |
#20 | |||
|
||||
Medlem
|
jag får precis samma som om man klickar på länken du lade in nu sist med "en" på slutet. Kan dock inte se något direkt svar utan bara de "inputVars" som skickades med.
Kod:
{"dapper":{"status":"OK","dappName":"Fetchwikipediacontent","dappTitle":"Fetch wikipedia content","urls":"\n * * *http:\/\/en.wikipedia.org\/wiki\/David_Beckham\n * * *http:\/\/en.wikipedia.org\/wiki\/Bob_Marley\n * *","applyToUrl":"http:\/\/en.wikipedia.org\/wiki\/David_Beckham","executionTime":"0.0070","ranAt":"2009-02-17 06:46:56","encoding":"UTF-8","ranEventChain":"true","inputVars":"\n * * *en\n * * *G\u00c3\u00b6ran H\u00c3\u00a4gglund\n * *"},"fields":{"ContentParts":[{"value":"To view this page without search results but with all search options, use Special:Search. For more information about searching Wikipedia, see Wikipedia:Searching. For image search there are more options at Wikimedia Commons search.","originalElement":"p","fieldName":"ContentParts"},{"value":"Note: Choosing the right search terms is the key to finding the information you need. If you add terms related to the general subject that the information you are searching for comes under, it may provide better results. Try to avoid searches containing only words in quotes, as they may not find a page you are looking for.","originalElement":"p","fieldName":"ContentParts"}]}} Jag har svårt att tro att detta skulle vara ett problem i .NET utan det är något annat som är strulet. Vill du se vad som händer i StreamReadern i debugg:en kan du sätta upp Visual Studio så att den laddar in .NET källkoden för StreamReadern under debuggen. Finns många exempel på hur man gör och här är ett. http://blogs.msdn.com/sburke/archive/2008/...ource-code.aspx |
|||
![]() |
![]() |
Svara |
Ämnesverktyg | |
Visningsalternativ | |
|
|