-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add main encoding detection functions #9
base: master
Are you sure you want to change the base?
Conversation
Actually, I'd now be inclined to throwing an exception when |
Thanks! Yes, having |
Here's a new version. What do you think of the name of the exception? |
I'm having second thoughts about the exception. Is there a scenario where both |
(Ptr{Void},Ptr{Int32},Ptr{UErrorCode}), | ||
csd.p, n, err) | ||
U_SUCCESS(err[1]) || error("ICU: could not detect encoding") | ||
n[1] > 0 || throw(UNoMatchingEncoding()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return an empty array instead of throwing an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? I first wanted to do that, but I though for consistency with ucsdet_detect
it would be better to throw an exception. As you like.
Actually, when no encoding matches, |
Bump! I have rebased this old branch. |
Could this be merged? We have a need for it also. Thanks! |
Re-bump! |
You might want to use https://github.com/JuliaString/ICU.jl instead, which supports the character detection API, fixes a bunch of errors with leaking memory (by adding finalizers and keeping a pointer to the other Julia object to prevent premature GC), and is tested (I am working on getting it to 100% coverage) |
Ah, cool. I guess it would make sense to redirect to your fork and register it in METADATA if you plan to maintain it in the future? |
Yes, that's what I was hoping for. I never did hear back from @nolta about that. If you get a chance, I'd love your comments on it, constructive criticism is very very much appreciated! |
I had wrapped some functions to convert from one encoding to another, and then I realized you had just done the same a few days ago. ;-) So I went on and wrote wrappers for encoding detection functions, which seem to work relatively well in the few tests I did.
Something I'm not sure I did right is what to do when
ucsdet_detect
returnsNULL
. I could returnC_NULL
ornothing
, which would break type stability. So for now I return an object with a null pointer, and I handle this inucsdet_getName
, by returning an empty encoding name.