|
|
|||
File indexing completed on 2026-10-03 09:17:24
0001 // Created on: 1996-09-26 0002 // Created by: Arnaud BOUZY 0003 // Copyright (c) 1996-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Resource_Unicode_HeaderFile 0018 #define _Resource_Unicode_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_CString.hxx> 0025 #include <Standard_Boolean.hxx> 0026 #include <Standard_PCharacter.hxx> 0027 #include <Standard_Integer.hxx> 0028 #include <Resource_FormatType.hxx> 0029 class TCollection_ExtendedString; 0030 0031 //! This class provides functions used to convert a non-ASCII C string 0032 //! given in ANSI, EUC, GB or SJIS format, to a 0033 //! Unicode string of extended characters, and vice versa. 0034 class Resource_Unicode 0035 { 0036 public: 0037 DEFINE_STANDARD_ALLOC 0038 0039 //! Converts non-ASCII CString <fromstr> in SJIS format 0040 //! to Unicode ExtendedString <tostr>. 0041 Standard_EXPORT static void ConvertSJISToUnicode(const char* const fromstr, 0042 TCollection_ExtendedString& tostr); 0043 0044 //! Converts non-ASCII CString <fromstr> in EUC format 0045 //! to Unicode ExtendedString <tostr>. 0046 Standard_EXPORT static void ConvertEUCToUnicode(const char* const fromstr, 0047 TCollection_ExtendedString& tostr); 0048 0049 //! Converts non-ASCII CString <fromstr> in GB format 0050 //! to Unicode ExtendedString <tostr>. 0051 Standard_EXPORT static void ConvertGBToUnicode(const char* const fromstr, 0052 TCollection_ExtendedString& tostr); 0053 0054 //! Converts non-ASCII CString <fromstr> in GBK format 0055 //! to Unicode ExtendedString <tostr>. 0056 Standard_EXPORT static bool ConvertGBKToUnicode(const char* const fromstr, 0057 TCollection_ExtendedString& tostr); 0058 0059 //! Converts non-ASCII CString <fromstr> in Big5 format 0060 //! to Unicode ExtendedString <tostr>. 0061 Standard_EXPORT static bool ConvertBig5ToUnicode(const char* const fromstr, 0062 TCollection_ExtendedString& tostr); 0063 0064 //! Converts Unicode ExtendedString <fromstr> to non-ASCII 0065 //! CString <tostr> in SJIS format, limited to <maxsize> 0066 //! characters. To translate the whole <fromstr>, use more 0067 //! than twice the length of <fromstr>. Returns true if 0068 //! <maxsize> has not been reached before end of conversion. 0069 Standard_EXPORT static bool ConvertUnicodeToSJIS(const TCollection_ExtendedString& fromstr, 0070 Standard_PCharacter& tostr, 0071 const int maxsize); 0072 0073 //! Converts Unicode ExtendedString <fromstr> to non-ASCII 0074 //! CString <tostr> in EUC format, limited to <maxsize> 0075 //! characters. To translate the whole <fromstr>, use more 0076 //! than twice the length of <fromstr>. Returns true if 0077 //! <maxsize> has not been reached before end of conversion. 0078 Standard_EXPORT static bool ConvertUnicodeToEUC(const TCollection_ExtendedString& fromstr, 0079 Standard_PCharacter& tostr, 0080 const int maxsize); 0081 0082 //! Converts Unicode ExtendedString <fromstr> to non-ASCII 0083 //! CString <tostr> in GB format, limited to <maxsize> 0084 //! characters. To translate the whole <fromstr>, use more 0085 //! than twice the length of <fromstr>. Returns true if 0086 //! <maxsize> has not been reached before end of conversion. 0087 Standard_EXPORT static bool ConvertUnicodeToGB(const TCollection_ExtendedString& fromstr, 0088 Standard_PCharacter& tostr, 0089 const int maxsize); 0090 0091 //! Converts Unicode ExtendedString <fromstr> to non-ASCII 0092 //! CString <tostr> in ANSI format, limited to <maxsize> 0093 //! characters. To translate the whole <fromstr>, use more 0094 //! than twice the length of <fromstr>. Returns true if 0095 //! <maxsize> has not been reached before end of conversion. 0096 Standard_EXPORT static bool ConvertUnicodeToANSI(const TCollection_ExtendedString& fromstr, 0097 Standard_PCharacter& tostr, 0098 const int maxsize); 0099 0100 //! Defines the current conversion format as typecode. 0101 //! This conversion format will then be used by the 0102 //! functions ConvertFormatToUnicode and 0103 //! ConvertUnicodeToFormat to convert the strings. 0104 Standard_EXPORT static void SetFormat(const Resource_FormatType typecode); 0105 0106 //! Returns the current conversion format (either 0107 //! ANSI, EUC, GB or SJIS). 0108 //! The current converting format must be defined in 0109 //! advance with the SetFormat function. 0110 Standard_EXPORT static Resource_FormatType GetFormat(); 0111 0112 //! Reads converting format from resource "FormatType" 0113 //! in Resource Manager "CharSet" 0114 Standard_EXPORT static void ReadFormat(); 0115 0116 //! Converts the non-ASCII C string (as specified by GetFormat()) to the Unicode string of 0117 //! extended characters. 0118 static void ConvertFormatToUnicode(const char* const theFromStr, 0119 TCollection_ExtendedString& theToStr) 0120 { 0121 return ConvertFormatToUnicode(Resource_Unicode::GetFormat(), theFromStr, theToStr); 0122 } 0123 0124 //! Converts the non-ASCII C string in specified format to the Unicode string of extended 0125 //! characters. 0126 //! @param[in] theFormat source encoding 0127 //! @param[in] theFromStr text to convert 0128 //! @param[out] theToStr destination string 0129 Standard_EXPORT static void ConvertFormatToUnicode(const Resource_FormatType theFormat, 0130 const char* const theFromStr, 0131 TCollection_ExtendedString& theToStr); 0132 0133 //! Converts the Unicode string of extended characters to the non-ASCII string according to 0134 //! specified format. You need more than twice the length of the source string to complete the 0135 //! conversion. The function returns true if conversion is complete, i.e. the maximum number of 0136 //! characters is not reached before the end of conversion. 0137 //! @param[in] theFormat destination encoding 0138 //! @param[in] theFromStr text to convert 0139 //! @param[out] theToStr destination buffer 0140 //! @param[in] theMaxSize destination buffer length 0141 Standard_EXPORT static bool ConvertUnicodeToFormat(const Resource_FormatType theFormat, 0142 const TCollection_ExtendedString& theFromStr, 0143 Standard_PCharacter& theToStr, 0144 const int theMaxSize); 0145 0146 //! Converts the Unicode string of extended characters to the non-ASCII string according to the 0147 //! format returned by the function GetFormat. 0148 //! @param[in] theFromStr text to convert 0149 //! @param[out] theToStr destination buffer 0150 //! @param[in] theMaxSize destination buffer length 0151 static bool ConvertUnicodeToFormat(const TCollection_ExtendedString& theFromStr, 0152 Standard_PCharacter& theToStr, 0153 const int theMaxSize) 0154 { 0155 return ConvertUnicodeToFormat(Resource_Unicode::GetFormat(), theFromStr, theToStr, theMaxSize); 0156 } 0157 }; 0158 0159 #endif // _Resource_Unicode_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|