include/relpipe/common/text/Iconv.h
branchv_0
changeset 18 9d566568d37c
child 20 a8ccd2b19faa
equal deleted inserted replaced
17:46151cd23815 18:9d566568d37c
       
     1 /**
       
     2  * Relational pipes (library)
       
     3  * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
       
     4  *
       
     5  * This program is free software: you can redistribute it and/or modify
       
     6  * it under the terms of the:
       
     7  *  - GNU Lesser General Public License as published by the Free Software Foundation;
       
     8  *    version 3 of the License or (at your option)
       
     9  *  - GNU General Public License as published by the Free Software Foundation;
       
    10  *    version 2 of the License.
       
    11  *
       
    12  * This program is distributed in the hope that it will be useful,
       
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    15  * GNU General Public License for more details.
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License
       
    18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    19  */
       
    20 #pragma once
       
    21 
       
    22 #include <string.h>
       
    23 #include <iconv.h>
       
    24 #include <string>
       
    25 #include <array>
       
    26 #include <assert.h>
       
    27 #include <ostream>
       
    28 #include <sstream>
       
    29 
       
    30 namespace relpipe {
       
    31 namespace common {
       
    32 namespace text {
       
    33 
       
    34 /**
       
    35  * Iconv class is a simple wrapper for iconv() functions.
       
    36  * It converts text from one encoding to another.
       
    37  * 
       
    38  * List of all encodings: iconv --list
       
    39  * 
       
    40  * n.b. if the default (platform) encoding "" is used, it is required to initialize locales: setlocale(LC_ALL, "");
       
    41  */
       
    42 class Iconv {
       
    43 private:
       
    44 	class IconvInternal;
       
    45 	IconvInternal* internal;
       
    46 public:
       
    47 	Iconv(std::string to, std::string from);
       
    48 	Iconv(std::string to, std::string from, size_t bufferSize);
       
    49 	virtual ~Iconv();
       
    50 	std::string convert(std::string originalText);
       
    51 };
       
    52 
       
    53 }
       
    54 }
       
    55 }