botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

UTF8 Encoding Issue in LUIS Query

Open eddie1976 opened this issue 10 years ago • 5 comments

In LuisService.cs, because of HttpUtility.ParseQueryString, LUIS Query (q) will be converted to UTF-8. As a result, what we got from LUIS (intent, score) are wrong.

e.g. "こんにちは!大家好" will be converted to "%u3053%u3093%u306b%u3061%u306f%uff01%u5927%u5bb6%u597d"

var queryString = HttpUtility.ParseQueryString(string.Empty); queryString["id"] = this.model.ModelID; queryString["subscription-key"] = this.model.SubscriptionKey; queryString["q"] = text;

eddie1976 avatar May 09 '16 07:05 eddie1976

Does https://github.com/Microsoft/BotBuilder/pull/76 solve your issue?

willportnoy avatar May 09 '16 18:05 willportnoy

#76 doesn't solve my issue. Now I use another work around to avoid UTF-8 issue.

HttpUtility.ParseQueryString(String) will parse a query string into a NameValueCollection using UTF8 encoding. Even though HttpUtility.ParseQueryString(String, Encoding) can be used with another encoding. I still think HttpUtility.UrlEncode should replace ParseQueryString in LuisService.cs because LUIS doesn't know URL parameter is encoded by ParseQueryString.

eddie1976 avatar May 10 '16 03:05 eddie1976

This seems to be the issue you're seeing, I presume:

http://stackoverflow.com/questions/829080/how-to-build-a-query-string-for-a-url-in-c#comment16989179_1877016

willportnoy avatar May 12 '16 03:05 willportnoy

So will you change HttpUtility.ParseQueryString to HttpUtility.UrlEncode?

eddie1976 avatar May 17 '16 03:05 eddie1976

Commit 8381544 should fix this issue.

msft-shahins avatar May 17 '16 23:05 msft-shahins