Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

iconv: don't use strncasecmp()

Don't use strncasecmp(), it's not available on Windows.
  • Loading branch information...
commit b953172a29dd22977c330714173185c1ad5fdbb6 1 parent ff87230
@bnoordhuis authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 iconv.cc
View
14 iconv.cc
@@ -6,7 +6,6 @@
#include <node_buffer.h>
#include <stdlib.h>
-#include <strings.h> // strcasecmp + strncasecmp
#include <string.h>
#include <errno.h>
@@ -187,10 +186,15 @@ Handle<Value> Iconv::Convert(const Arguments& args) {
// workaround for shortcoming in libiconv: "UTF-8" is recognized but "UTF8" isn't
Handle<String> FixEncodingName(Handle<String> name) {
- String::AsciiValue s(name);
-
- if (!strncasecmp(*s, "UTF", 3) && (*s)[3] != '-') {
- std::string rv = std::string("UTF-") + (*s + 3);
+ String::AsciiValue str(name);
+ const char* s = *str;
+
+ if ((s[0] == 'U' || s[0] == 'u') &&
+ (s[1] == 'T' || s[1] == 't') &&
+ (s[2] == 'F' || s[2] == 'f') &&
+ (s[3] != '-'))
+ {
+ std::string rv = std::string("UTF-") + &s[3];
return String::New(rv.c_str());
}
Please sign in to comment.
Something went wrong with that request. Please try again.