summaryrefslogtreecommitdiff
path: root/lib_dxf/intern/drw_textcodec.h
diff options
context:
space:
mode:
authorsaurabhb172020-02-26 16:20:48 +0530
committerGitHub2020-02-26 16:20:48 +0530
commitb77f5d9d8097c38159c6f60917995d6af13bbe1c (patch)
tree1392c90227aeea231c1d86371131e04c40382918 /lib_dxf/intern/drw_textcodec.h
parentdadc4d490966a24efe15b5cc533ef8695986048a (diff)
parent003d02608917e7a69d1a98438837e94ccf68352a (diff)
downloadKiCad-eSim-b77f5d9d8097c38159c6f60917995d6af13bbe1c.tar.gz
KiCad-eSim-b77f5d9d8097c38159c6f60917995d6af13bbe1c.tar.bz2
KiCad-eSim-b77f5d9d8097c38159c6f60917995d6af13bbe1c.zip
Merge pull request #4 from FOSSEE/develop
merging dev into master
Diffstat (limited to 'lib_dxf/intern/drw_textcodec.h')
-rw-r--r--lib_dxf/intern/drw_textcodec.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/lib_dxf/intern/drw_textcodec.h b/lib_dxf/intern/drw_textcodec.h
new file mode 100644
index 0000000..1a8c56a
--- /dev/null
+++ b/lib_dxf/intern/drw_textcodec.h
@@ -0,0 +1,99 @@
+#ifndef DRW_TEXTCODEC_H
+#define DRW_TEXTCODEC_H
+
+#include <string>
+
+class DRW_Converter;
+
+class DRW_TextCodec
+{
+public:
+ DRW_TextCodec();
+ ~DRW_TextCodec();
+ std::string fromUtf8( std::string s );
+ std::string toUtf8( std::string s );
+
+ int getVersion() { return version; }
+ void setVersion( std::string* v );
+
+ void setVersion( int v ) { version = v; }
+ void setCodePage( std::string* c );
+
+ void setCodePage( std::string c ) { setCodePage( &c ); }
+ std::string getCodePage() { return cp; }
+
+private:
+ std::string correctCodePage( const std::string& s );
+
+private:
+ int version;
+ std::string cp;
+ DRW_Converter* conv;
+};
+
+class DRW_Converter
+{
+public:
+ DRW_Converter( const int* t, int l )
+ {
+ table = t;
+ cpLenght = l;
+ }
+
+ virtual ~DRW_Converter() {}
+ virtual std::string fromUtf8( std::string* s ) { return *s; }
+ virtual std::string toUtf8( std::string* s );
+ std::string encodeText( std::string stmp );
+ std::string decodeText( int c );
+ std::string encodeNum( int c );
+ int decodeNum( std::string s, int* b );
+
+ const int* table;
+ int cpLenght;
+};
+
+class DRW_ConvTable : public DRW_Converter
+{
+public:
+ DRW_ConvTable( const int* t, int l ) : DRW_Converter( t, l ) {}
+ virtual std::string fromUtf8( std::string* s );
+ virtual std::string toUtf8( std::string* s );
+};
+
+class DRW_ConvDBCSTable : public DRW_Converter
+{
+public:
+ DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
+ l )
+ {
+ leadTable = lt;
+ doubleTable = dt;
+ }
+
+ virtual std::string fromUtf8( std::string* s );
+ virtual std::string toUtf8( std::string* s );
+
+private:
+ const int* leadTable;
+ const int (*doubleTable)[2];
+};
+
+class DRW_Conv932Table : public DRW_Converter
+{
+public:
+ DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
+ l )
+ {
+ leadTable = lt;
+ doubleTable = dt;
+ }
+
+ virtual std::string fromUtf8( std::string* s );
+ virtual std::string toUtf8( std::string* s );
+
+private:
+ const int* leadTable;
+ const int (*doubleTable)[2];
+};
+
+#endif // DRW_TEXTCODEC_H