-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
String == String does not work with embedded NUL characters #112
Comments
Also, ArduinoCore-API/api/String.cpp Line 467 in 7f8de58
ArduinoCore-API/api/String.cpp Line 492 in 7f8de58
ArduinoCore-API/api/String.cpp Line 498 in 7f8de58
You can debate if there is a change needed to ArduinoCore-API/api/String.cpp Line 470 in 7f8de58
String::equalsIgnoreCase implies only printable characters.
|
Did you see #97? It is related and I think it might solve your issue (but it's been too long since I wrote it, so I cannot recall exactly). |
Yes, I saw your pull request (and commented on it). As far as I can see, it
still has strcmp() calls in it... please correct me if I'm wrong!
Christ van Willegen
|
Instead of strcmp(), try using stricmp(). It may work |
@cvwillegen, seems you're right, I should probaly dust off that PR sometime and also fix those calls... @prath06, but it seems that |
In C, C strings are just an array of chars terminated by NULL. That is how strcmp(), strcpy(), etc know where the end of the string is. The Arduino String class does a nice job hiding those implementation details, but the fact remains: embedded nulls in Strings WILL BREAK THINGS. |
Sure, that's how C strings work. But the Sure, we could define this as an (artificial) limitation on the |
|
ArduinoCore-API/api/String.cpp
Line 445 in 7f8de58
ArduinoCore-API/api/String.cpp
Line 445 in 7f8de58
memcmp()
to make sure that a String object can be compared to another String object that has embeddedNUL
charactersThe text was updated successfully, but these errors were encountered: