📄 utf_functions.h
字号:
/*
* Written by Boby Thomas Pazheparampil. (March 2007.)
* Platform independent code. (I hope so)
* Tested with Windows 2000, XP, Cygwin and Linux Debian.
*/
#ifndef utf_functions_h__
#define utf_functions_h__
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
/*************************************************************************
* @f Fnct : convertHex2UTF
* @r Return : single character UTF string.
* Description : Convert stl hex charater string to corresponding
UTF character string. Do not misunderstand this function
with a stream converter. This function converts only one
character.
For example
"7f" return "7f"
"80" return "c280"
"fffd" return "efbfbd"
* @author : Boby thomas
**************************************************************************/
string convertHex2UTF(string);
/*************************************************************************
* @f Fnct : convertUTF2Hex
* @r Return : Hex value corresponding to the UTF chracter.
"error" on invalid character.
* Description : Returns the hex value corresponding to a UTF character.
Do not misunderstand this function with a stream converter.
This function convert only one UTF-8 character.
For example
"7f" return "7f"
"c280" return "80"
"efbfbd" return "fffd"
* @author : Boby thomas
**************************************************************************/
string convertUTF2Hex(string);
/*************************************************************************
* @f Fnct : findLengthUTF
* @r Return : single character. Normaly first character of a UTF stream.
-1 for invalid UTF entry.
* Description : Returns the number of characters in the UTF string.
Say for example 0xc2 will return 2 since one more byte
following this will constitute the UTF character.
* @author : Boby thomas
**************************************************************************/
long findLengthUTF(string sUTFFirstByte);
/*************************************************************************
* @f Fnct : generateUTFFileDetails
* @r Return : true - file could be a UTF file.
(No invalid UTF character in the file)
* Description : This function evaluate a file for validity. Returns false
if there a single occurance of a nonpossible character.
Writes a file utfdetails_<filename> with all the utf
character details.
* @author : Boby thomas
**************************************************************************/
bool generateUTFFileDetails(string sFileName);
/*************************************************************************
* @f Fnct : hex2binary
* @r Return : Binary string.
* Description : Convert stl string of hex values to a binary string.
* @author : Boby thomas
**************************************************************************/
string hex2binary(string sAscii);
/*************************************************************************
* @f Fnct : binary2hex
* @r Return : Hexadecimal string.
* Description : Convert stl binary string to of hex value string.
Accept binary string of any length.
* @author : Boby thomas
**************************************************************************/
string binary2hex(string sBinary);
#endif //utf_functions_h__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -