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

MatChar equality is now based only on character content #26

Merged
merged 1 commit into from
Dec 7, 2018

Conversation

nedtwigg
Copy link
Contributor

@nedtwigg nedtwigg commented Dec 6, 2018

Possible resolution of #21

I think it was smart to separate the peculiarities of MATLAB's fileformat vs the actual semantic data in the format vs types package as you have done. format.CharEncoding really is Mat5 specific - I hadn't realized the issues around endian-ness and 16-bit ASCII. Because it's Mat5 specific, I don't think it makes sense to move it to types, which means we can't really add it to Char either.

What do you think about this little cheat?

@ennerf
Copy link
Collaborator

ennerf commented Dec 6, 2018

On second thought, do you have an actual use case for retrieving the backing encoding of an existing char array?

After doing a quick search I didn't find any equivalent functionality in MATLAB. native2unicode and unicode2native only convert to and from binary representations.

@nedtwigg
Copy link
Contributor Author

nedtwigg commented Dec 6, 2018

If it's not possible to access the encoding in MATLAB, then I guess I don't :) And in that case, I should adjust the implementation of .equals() and .hashCode() to be encoding-agnostic, yeah?

@ennerf
Copy link
Collaborator

ennerf commented Dec 6, 2018

I think it should be ok to just check the equality for the char[] array. The encoding is only used for converting to and from binary data, so it has no impact on the data once it's loaded.

The only use case I can think of is when someone loads an existing .mat file and modifies a contained CharArray with unicode characters that are not covered by the previous encoding. In that case something like a setter or an automatic upgrade to a higher encoding would probably make more sense. It's such a corner case though that I'd be happy to ignore it until someone files an issue.

@nedtwigg nedtwigg changed the title Added an escape hatch to access the encoding of a MatChar. MatChar equality is now based only on character content Dec 7, 2018
@ennerf ennerf merged commit 5759500 into HebiRobotics:develop Dec 7, 2018
@ennerf
Copy link
Collaborator

ennerf commented Dec 7, 2018

Thanks

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

Successfully merging this pull request may close these issues.

2 participants