summaryrefslogtreecommitdiff
path: root/tools/iconv.h
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2008-02-28 06:10:55 +0000
committercvs2svn <admin@example.com>2008-02-28 06:10:55 +0000
commitf676de20d91ba1cc58b8eaaf2f6b931851c2063a (patch)
tree69a3aa7a4da079ef4de5aa12ab0563d2945f2a23 /tools/iconv.h
parent4e3b041c65f36dd8729ca2b5fe224461a2166f6d (diff)
downloadxineliboutput-f676de20d91ba1cc58b8eaaf2f6b931851c2063a.tar.gz
xineliboutput-f676de20d91ba1cc58b8eaaf2f6b931851c2063a.tar.bz2
This commit was manufactured by cvs2svn to create branch 'unlabeled-1.3.2'.
Diffstat (limited to 'tools/iconv.h')
-rw-r--r--tools/iconv.h100
1 files changed, 0 insertions, 100 deletions
diff --git a/tools/iconv.h b/tools/iconv.h
deleted file mode 100644
index 3ce0fb28..00000000
--- a/tools/iconv.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * iconv.h: iconv library wrapper
- *
- * See the main source file 'xineliboutput.c' for copyright information and
- * how to reach the author.
- *
- * $Id: iconv.h,v 1.5 2007-09-18 09:13:13 phintuka Exp $
- *
- */
-
-#ifndef _XINELIBOUTPUT_ICONV_H_
-#define _XINELIBOUTPUT_ICONV_H_
-
-#if defined(USE_ICONV) && USE_ICONV == 0
-# undef USE_ICONV
-# warning iconv disabled
-#endif
-
-#ifdef USE_ICONV
-# include <iconv.h>
-#endif
-
-class cIConv
-{
-#ifdef USE_ICONV
- private:
- iconv_t m_ic;
-#endif
-
- public:
- cIConv(const char *SrcCharset = NULL, const char * DstCharset = NULL);
- virtual ~cIConv();
-
- cString Translate(const char *Text) const;
-};
-
-cIConv::cIConv(const char *SrcCharset, const char * DstCharset)
-{
-#ifdef USE_ICONV
- if(!SrcCharset)
- SrcCharset = "UTF-8";
- if(!DstCharset) {
-#if APIVERSNUM >= 10503
- DstCharset = cCharSetConv::SystemCharacterTable();
-#else
- DstCharset = I18nCharSets()[Setup.OSDLanguage];
-#endif
- }
- m_ic = (iconv_t)-1;
-
- if(DstCharset) {
- m_ic = iconv_open(DstCharset, SrcCharset);
-
- if(m_ic == (iconv_t)-1)
- LOGERR("cIConv: iconv_open(\"%s\",\"%s\") failed",
- SrcCharset, DstCharset);
- }
-#endif
-}
-
-cIConv::~cIConv()
-{
-#ifdef USE_ICONV
- if(m_ic != (iconv_t)-1)
- iconv_close(m_ic);
-#endif
-}
-
-cString cIConv::Translate(const char *Text) const
-{
-#ifdef USE_ICONV
- if(m_ic == (iconv_t)-1)
- return cString(Text);
-
- size_t inc = strlen(Text);
- size_t outc = inc<2048 ? 2048 : inc+1;
-#ifdef __APPLE__
- const char *in = Text;
-#else
- char *in = (char*)Text;
-#endif
- char *buf = (char*)malloc(outc+1);
- char *out = buf;
-
- size_t n = iconv(m_ic, &in, &inc, &out, &outc);
-
- if(n != (size_t)-1) {
- *out = 0;
- return cString(buf, true);
- }
-
- LOGERR("cIConv: iconv(%s) failed at %d", Text, (int)(in - Text));
- free(buf);
-#endif
-
- return cString(Text);
-}
-
-
-#endif // _XINELIBOUTPUT_ICONV_H_