Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it UTF8 encoded or base 64? #4

Open
ritesh124 opened this issue Sep 25, 2018 · 2 comments
Open

Is it UTF8 encoded or base 64? #4

ritesh124 opened this issue Sep 25, 2018 · 2 comments

Comments

@ritesh124
Copy link

ritesh124 commented Sep 25, 2018

I am using to publish iBeacons, But i don't know in what format this library encodes it.
While I am trying to scan it by Google NearBy, I am not able to read it.
As Google NearBy Doc Says.

mMessageListener = new MessageListener() {
    @Override
    public void onFound(Message message) {
        // Do something with the message here.
        Log.i(TAG, "Message found: " + message);
        Log.i(TAG, "Message string: " + new String(message.getContent()));
        Log.i(TAG, "Message namespaced type: " + message.getNamespace() +
                "/" + message.getType());
    }

    ...
};
Parsing the content depends on the format of the bytes. This example assumes that the content bytes encode a UTF-8 string, but your beacon message can encode other byte formats (for example a serialized protocol buffer)

So when I am trying to Log the above method provided by Google Nearby Messages API.

bytes
msg_cntnt

@adriancretu
Copy link
Owner

UTF-8 is a string encoding (and the default one in Android's Java). iBeacon is a binary format (16 bytes UUID + 4 bytes major/minor + 1 byte TX ref power), plus the extra Manufacturer Data overhead. Why on earth would you want to try and convert a random binary buffer to a UTF-8 String? It might even throw exceptions if invalid code points get detected,

@ritesh124
Copy link
Author

Thanks, It worked 😝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants