2

Apparently SSIDs can contain UTF-8 chars and also control characters etc. IIUC to contain UTF-8 chars they must specify the SSIDEncoding field. I was under the impression that I can only get ASCII bytes till now.

How should I handle the situation in Android ? Namely, how can I check the SSIDEncoding field from the ScanResult ? Do I need to ? Also what does ScanResult.SSID contain in these cases (including the case an SSID includes non printable characters) ?

Related

Community
  • 1
  • 1
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361

1 Answers1

-1

The short answer is that you can't detect it, but you don't need to.

Android only returns a String in ScanResult and WifiConfiguration (There is no documented encoding field). Since Java Strings can contain accept different encodings, but internally store unicode (How to check the charset of string in Java?) then the original encoding is lost in translation. But if all you need is a String and you are using APIs and storage mechanisms that accept Java String then all of those things should already support encoding that String to whatever format they require and you probably have nothing to worry about.

I can't speak to what Android does under the covers with respect to giving you that String, but the link you provided provides some ideas. If Android does or does not support different encoding types for the SSID, there's nothing you can do about it.

Community
  • 1
  • 1
Eric Woodruff
  • 6,380
  • 3
  • 36
  • 33
  • There is - talking to the service in C++ - did you read the question carefully ? – Mr_and_Mrs_D Apr 01 '14 at 12:54
  • Maybe you should clarify the question, there is no reference to C++ – Eric Woodruff Apr 01 '14 at 17:25
  • yes because it may not be needed. But in the bounty notice it says : ___as discussed in the question linked it is probable that "..you need to deal directly with the wifi service to get the raw scan result"___. If you can deal in Java so much the better – Mr_and_Mrs_D Apr 01 '14 at 17:56
  • There's still nothing in that comment that talks about C++. It seems to be referencing http://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults() which is in line with my answer. – Eric Woodruff Apr 01 '14 at 19:05
  • " the raw scan result" is what is returned by `getScanResults ()` ?! Did you really read the comment ? The wifi service with " the raw scan result" you believe is in java ? _Where_ ? – Mr_and_Mrs_D Apr 01 '14 at 20:03
  • This is java: WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); – Eric Woodruff Apr 01 '14 at 20:07
  • Does it make sense? The Java String returned is unicode, not ASCII, all Java Strings are unicode. So what are you doing that is assuming that Java Strings are ASCII? – Eric Woodruff Apr 02 '14 at 22:32