Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/257#discussion_r49366818
--- Diff: core/sql/common/csconvert.cpp ---
@@ -1275,3 +1279,41 @@ char * findStartOfChar( char *someByteInChar, char
*startOfBuffer )
rtnv-- ;
return rtnv ;
}
+/* A method to do character set conversion , using Glibc iconv */
+int code_convert(const char *from_charset,const char *to_charset,char
*inbuf, size_t inlen, char *outbuf,size_t outlen)
+{
+ iconv_t cd;
+ int rc;
+ char **pin = &inbuf;
+ char **pout = &outbuf;
+
+ cd = iconv_open(to_charset,from_charset);
+ if (cd==0) return -1;
+ memset(outbuf,0,outlen);
+ if (iconv(cd,pin,(size_t*)&inlen,pout,(size_t *)&outlen)==-1)
+ {
+ iconv_close(cd);
+ return -1;
+ }
+ iconv_close(cd);
+ return outlen;
+}
+/* from gbk to utf8 */
+int gbk2utf8(char *inbuf,size_t inlen,char *outbuf,size_t outlen)
+{
+ return code_convert("gbk","utf-8",inbuf,inlen,outbuf,outlen);
+}
+
+int gbkToUtf8(char* gbkString, size_t gbklen,
+ char* result ,size_t outlen, int addNullAtEnd)
--- End diff --
Would bool be a better data type for addNullAtEnd?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---