This project has moved. For the latest updates, please go here.
2
Vote

Unable to search with UTF8 Chars in Search Query

description

Hello,

I am trying to search statuses with a query which contains Turkish Characters. However, I am getting unauth error. When I replace Turkish chars with latin letters ( For exp; ö to o) it works.

Sample Code:
             var dateNow = DateTime.UtcNow.Year + "-" + DateTime.UtcNow.Month + "-" + DateTime.UtcNow.AddHours(-6).Day;
            var searchTag = "#ömer -RT -instagram -source:foursquare" + " since:" + dateNow;

            var queryResults =
                (from search in context.Search
                 where search.Type == SearchType.Search &&
                       search.Query == searchTag &&
                       search.Count == 200 &&
                       search.SinceID == sinceIdLong
                 select search);
              var srch = queryResults.SingleOrDefault();

How Can I Fix this issue?

Thanks,
Mert

comments

JoeMayo wrote Feb 2, 2015 at 5:36 PM

The problem doesn't appear in the Turkish character encoding. By divide-and-conquer I discovered that the problem is happening in "-source:foursquare". Looking at the Search Operators, it appears that parameter should be "news source:foursquare". For some reason, the ':' isn't being encoded by HttpClient, but changing it to '%3A' eliminates the error.

Mertkurum wrote Feb 5, 2015 at 12:23 AM

Still it is not working. I am not getting exception now but I doesnt give the correct results.
         var dateNow = DateTime.UtcNow.Year + "-" + DateTime.UtcNow.Month + "-" + DateTime.UtcNow.AddHours(-6).Day;
        var searchTag = "#ömer -RT -instagram -source%3Afoursquare" + " since%3A" + dateNow;

        var queryResults =
            (from search in context.Search
             where search.Type == SearchType.Search &&
                   search.Query == searchTag &&
                   search.Count == 200 &&
                   search.SinceID == sinceIdLong
             select search);
          var srch = queryResults.SingleOrDefault();
However, If I remove "since:" it works. If I leave "since:" without changing ":" it gives error.

Mertkurum wrote Apr 11, 2015 at 9:01 PM

Are you going to fix this issue??