Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/257#discussion_r49496156
  
    --- Diff: core/sql/common/csconvert.cpp ---
    @@ -1275,3 +1279,47 @@ 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);
    +}
    +
    +/* convert gbk string into UTF8 */
    +int gbkToUtf8(char* gbkString, size_t gbklen, 
    --- End diff --
    
    Having two methods with almost the same name and almost the same parameter 
list is very hard to read. I find that very confusing. Could we give them more 
different names? Or, maybe just have a single method with an optional parameter?


---
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.
---

Reply via email to