1 // ----------------------------------------------------------------------------
2 // outputencoder.h  --  output charset conversion
3 //
4 // Copyright (C) 2012
5 //		Andrej Lajovic, S57LN
6 //
7 // This file is part of fldigi.
8 //
9 // Fldigi is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // Fldigi is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with fldigi.  If not, see <http://www.gnu.org/licenses/>.
21 // ----------------------------------------------------------------------------
22 
23 #ifndef OUTPUTENCODER_H
24 #define OUTPUTENCODER_H
25 
26 #include <string>
27 #include <tiniconv.h>
28 
29 class OutputEncoder
30 {
31 	public:
32 		OutputEncoder(const int charset_out = TINICONV_CHARSET_UTF_8, unsigned int buffer_size = 32);
33 		~OutputEncoder(void);
34 		void set_output_encoding(const int charset_out);
35 		void push(std::string s);
36 		const unsigned int pop(void);
37 		const unsigned int peek(void);
38 
39 	private:
40 		unsigned int buffer_size;
41 		unsigned char *buffer;
42 		unsigned char *encoding_ptr;
43 		unsigned char *pop_ptr;
44 		//unsigned int data_length;
45 		tiniconv_ctx_s ctx;
46 };
47 
48 #endif
49