const char *string(static_cast<const char *>(internal->value_));
std::ostringstream str;
str << "&";
- CYStringify(str, string, strlen(string));
+ CYStringify(str, string, strlen(string), true);
std::string value(str.str());
return CYCastJSValue(context, CYJSString(CYUTF8String(value.c_str(), value.size())));
} CYCatch(NULL) }
}
/* }}} */
/* JavaScript *ify {{{ */
-void CYStringify(std::ostringstream &str, const char *data, size_t size) {
- unsigned quot(0), apos(0);
- for (const char *value(data), *end(data + size); value != end; ++value)
- if (*value == '"')
- ++quot;
- else if (*value == '\'')
- ++apos;
-
- bool single(quot > apos);
+void CYStringify(std::ostringstream &str, const char *data, size_t size, bool c) {
+ bool single;
+ if (c)
+ single = false;
+ else {
+ unsigned quot(0), apos(0);
+ for (const char *value(data), *end(data + size); value != end; ++value)
+ if (*value == '"')
+ ++quot;
+ else if (*value == '\'')
+ ++apos;
+
+ single = quot > apos;
+ }
str << (single ? '\'' : '"');
if (!objective)
str << '@';
CYUTF8String string(CYCastUTF8String(self));
- CYStringify(str, string.data, string.size);
+ CYStringify(str, string.data, string.size, true);
std::string value(str.str());
return CYCastNSString(NULL, CYUTF8String(value.c_str(), value.size()));
}
bool CYSendAll_(int socket, const uint8_t *data, size_t size);
void CYNumerify(std::ostringstream &str, double value);
-void CYStringify(std::ostringstream &str, const char *data, size_t size);
+void CYStringify(std::ostringstream &str, const char *data, size_t size, bool c = false);
double CYCastDouble(const char *value, size_t size);
double CYCastDouble(const char *value);