?? uniconv390transservice.cpp
字號:
gMappings->put((void*)XMLUni::fgIBM1140EncodingString4, new ENameMapFor<XMLIBM1140Transcoder390>(XMLUni::fgIBM1140EncodingString4)); // // Add in our mappings for Windows-1252. We don't have any aliases for // this one, so there is just one mapping. // gMappings->put((void*)XMLUni::fgWin1252EncodingString, new ENameMapFor<XMLWin1252Transcoder390>(XMLUni::fgWin1252EncodingString)); } // use new intrinsics else // use old intrinsics { // // A stupid way to increment the fCurCount inside the RefVectorOf // for (unsigned int i = 0; i < XMLRecognizer::Encodings_Count; i++) gMappingsRecognizer->addElement(0); // // Add in the magical mapping for the native XMLCh transcoder. This // is used for internal entities. // gMappingsRecognizer->setElementAt(new ENameMapFor<XMLChTranscoder>(XMLUni::fgXMLChEncodingString), XMLRecognizer::XERCES_XMLCH); gMappings->put((void*)XMLUni::fgXMLChEncodingString, new ENameMapFor<XMLChTranscoder>(XMLUni::fgXMLChEncodingString)); // // Add in our mappings for ASCII. // gMappingsRecognizer->setElementAt(new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString), XMLRecognizer::US_ASCII); gMappings->put((void*)XMLUni::fgUSASCIIEncodingString, new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString)); gMappings->put((void*)XMLUni::fgUSASCIIEncodingString2, new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString2)); gMappings->put((void*)XMLUni::fgUSASCIIEncodingString3, new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString3)); gMappings->put((void*)XMLUni::fgUSASCIIEncodingString4, new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString4)); // // Add in our mappings for UTF-8 // gMappingsRecognizer->setElementAt(new ENameMapFor<XMLUTF8Transcoder>(XMLUni::fgUTF8EncodingString), XMLRecognizer::UTF_8); gMappings->put((void*)XMLUni::fgUTF8EncodingString, new ENameMapFor<XMLUTF8Transcoder>(XMLUni::fgUTF8EncodingString)); gMappings->put((void*)XMLUni::fgUTF8EncodingString2, new ENameMapFor<XMLUTF8Transcoder>(XMLUni::fgUTF8EncodingString2)); // // Add in our mappings for Latin1 // gMappings->put((void*)XMLUni::fgISO88591EncodingString, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString)); gMappings->put((void*)XMLUni::fgISO88591EncodingString2, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString2)); gMappings->put((void*)XMLUni::fgISO88591EncodingString3, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString3)); gMappings->put((void*)XMLUni::fgISO88591EncodingString4, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString4)); gMappings->put((void*)XMLUni::fgISO88591EncodingString5, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString5)); gMappings->put((void*)XMLUni::fgISO88591EncodingString6, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString6)); gMappings->put((void*)XMLUni::fgISO88591EncodingString7, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString7)); gMappings->put((void*)XMLUni::fgISO88591EncodingString8, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString8)); gMappings->put((void*)XMLUni::fgISO88591EncodingString9, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString9)); gMappings->put((void*)XMLUni::fgISO88591EncodingString10, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString10)); gMappings->put((void*)XMLUni::fgISO88591EncodingString11, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString11)); gMappings->put((void*)XMLUni::fgISO88591EncodingString12, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString12)); // // Add in our mappings for UTF-16 and UCS-4, little endian // bool swapped = false; #if defined(ENDIANMODE_BIG) swapped = true; #endif gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16LEncodingString, swapped), XMLRecognizer::UTF_16L); gMappings->put ( (void*)XMLUni::fgUTF16LEncodingString, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16LEncodingString , swapped ) ); gMappings->put ( (void*)XMLUni::fgUTF16LEncodingString2, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16LEncodingString2 , swapped ) ); gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUCS4Transcoder>(XMLUni::fgUCS4LEncodingString, swapped), XMLRecognizer::UCS_4L); gMappings->put ( (void*)XMLUni::fgUCS4LEncodingString, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4LEncodingString , swapped ) ); gMappings->put ( (void*)XMLUni::fgUCS4LEncodingString2, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4LEncodingString2 , swapped ) ); // // Add in our mappings for UTF-16 and UCS-4, big endian // swapped = false; #if defined(ENDIANMODE_LITTLE) swapped = true; #endif gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16BEncodingString, swapped), XMLRecognizer::UTF_16B); gMappings->put ( (void*)XMLUni::fgUTF16BEncodingString, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16BEncodingString , swapped ) ); gMappings->put ( (void*)XMLUni::fgUTF16BEncodingString2, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16BEncodingString2 , swapped ) ); gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUCS4Transcoder>(XMLUni::fgUCS4BEncodingString, swapped), XMLRecognizer::UCS_4B); gMappings->put ( (void*)XMLUni::fgUCS4BEncodingString, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4BEncodingString , swapped ) ); gMappings->put ( (void*)XMLUni::fgUCS4BEncodingString2, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4BEncodingString2 , swapped ) ); // // Add in our mappings for UTF-16 and UCS-4 which does not indicate endian // assumes the same endian encoding as the OS // gMappings->put ( (void*)XMLUni::fgUTF16EncodingString, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16EncodingString , false ) ); gMappings->put ( (void*)XMLUni::fgUTF16EncodingString2, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16EncodingString2 , false ) ); gMappings->put ( (void*)XMLUni::fgUTF16EncodingString3, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16EncodingString3 , false ) ); gMappings->put ( (void*)XMLUni::fgUTF16EncodingString4, new EEndianNameMapFor<XMLUTF16Transcoder> ( XMLUni::fgUTF16EncodingString4 , false ) ); gMappings->put ( (void*)XMLUni::fgUCS4EncodingString, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4EncodingString , false ) ); gMappings->put ( (void*)XMLUni::fgUCS4EncodingString2, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4EncodingString2 , false ) ); gMappings->put ( (void*)XMLUni::fgUCS4EncodingString3, new EEndianNameMapFor<XMLUCS4Transcoder> ( XMLUni::fgUCS4EncodingString3 , false ) ); // // Add in our mappings for IBM037, and the one alias we support for // it, which is EBCDIC-CP-US. // gMappingsRecognizer->setElementAt(new ENameMapFor<XMLEBCDICTranscoder>(XMLUni::fgEBCDICEncodingString), XMLRecognizer::EBCDIC); gMappings->put((void*)XMLUni::fgIBM037EncodingString, new ENameMapFor<XMLEBCDICTranscoder>(XMLUni::fgIBM037EncodingString)); gMappings->put((void*)XMLUni::fgIBM037EncodingString2, new ENameMapFor<XMLEBCDICTranscoder>(XMLUni::fgIBM037EncodingString2)); //hhe gMappings->put((void*)XMLUni::fgIBM1047EncodingString, new ENameMapFor<XMLIBM1047Transcoder>(XMLUni::fgIBM1047EncodingString)); gMappings->put((void*)XMLUni::fgIBM1047EncodingString2, new ENameMapFor<XMLIBM1047Transcoder>(XMLUni::fgIBM1047EncodingString2)); // // Add in our mappings for IBM037 with Euro update, i.e. IBM1140. It // has alias IBM01140, the one suggested by IANA // gMappings->put((void*)XMLUni::fgIBM1140EncodingString, new ENameMapFor<XMLIBM1140Transcoder>(XMLUni::fgIBM1140EncodingString)); gMappings->put((void*)XMLUni::fgIBM1140EncodingString2, new ENameMapFor<XMLIBM1140Transcoder>(XMLUni::fgIBM1140EncodingString2)); gMappings->put((void*)XMLUni::fgIBM1140EncodingString3, new ENameMapFor<XMLIBM1140Transcoder>(XMLUni::fgIBM1140EncodingString3)); gMappings->put((void*)XMLUni::fgIBM1140EncodingString4, new ENameMapFor<XMLIBM1140Transcoder>(XMLUni::fgIBM1140EncodingString4)); // // Add in our mappings for Windows-1252. We don't have any aliases for // this one, so there is just one mapping. // gMappings->put((void*)XMLUni::fgWin1252EncodingString, new ENameMapFor<XMLWin1252Transcoder>(XMLUni::fgWin1252EncodingString)); } // use old intrinsics}//end initTransService()// ***************************************************************************// ***************************************************************************// ***************************************************************************// ***************************************************************************// *************** Uniconv390Transcoder Class ********************************// ***************************************************************************// ***************************************************************************// ***************************************************************************// ***************************************************************************// ---------------------------------------------------------------------------// Uniconv390Transcoder: Constructors and Destructor// ---------------------------------------------------------------------------Uniconv390Transcoder::Uniconv390Transcoder(const XMLCh* const encodingName , uniconvconverter_t * const toAdopt , const unsigned int blockSize , MemoryManager* const manager) : XMLTranscoder(encodingName, blockSize, manager) , fConverter(toAdopt){}Uniconv390Transcoder::~Uniconv390Transcoder(){ // If there is a converter, clean it up if (fConverter) { removeConverter(fConverter); fConverter=0; }}// ---------------------------------------------------------------------------// Uniconv390Transcoder: The virtual transcoder API// ---------------------------------------------------------------------------// ignore charSizes since that is used to generate character offsets.unsigned intUniconv390Transcoder::transcodeFrom(const XMLByte* const srcData , const unsigned int srcCount , XMLCh* const toFill , const unsigned int maxChars , unsigned int& bytesEaten , unsigned char* const charSizes){ unsigned int countIn = 0; unsigned int countOut = 0;DBGPRINTF2("Uniconv390Transcoder::transcodeFrom bytes=%d\n",srcCount); int retCode; char *tmpInPtr = (char *) srcData; char *tmpOutPtr = (char *) toFill; unsigned int inByteLeft = srcCount; unsigned int outByteLeft = maxChars*sizeof(XMLCh); { // locking scope XMLMutexLock lockConverter(&fConverter->fMutex); retCode = uniconv(fConverter->fIconv390DescriptorFrom, &tmpInPtr, &inByteLeft, &tmpOutPtr, &outByteLeft); }DBGPRINTF5("Uniconv390Transcoder::transcodeFrom iconv finished, rc=%d inleft=%d outleft=%d errno=%d \n",retCode,inByteLeft,outByteLeft,errno); if ( (retCode < 0 ) && (errno != E2BIG) ) { return 0; } // Give back the counts of eaten and transcoded bytesEaten = srcCount-inByteLeft; return maxChars-outByteLeft/sizeof(XMLCh);}// The returned int is really supposed to be the number of bytes, not chars!unsigned intUniconv390Transcoder::transcodeTo( const XMLCh* const srcData , const unsigned int srcCount , XMLByte* const toFill , const unsigned int maxBytes , unsigned int& charsEaten , const UnRepOpts options){ unsigned int countIn = 0; unsigned int countOut = 0;DBGPRINTF2("Uniconv390Transcoder::transcodeTo bytes=%d\n",srcCount); int retCode; char *tmpInPtr = (char *) srcData; char *tmpOutPtr = (char *) toFill; unsigned int inByteLeft = srcCount*sizeof(XMLCh); unsigned int outByteLeft = maxBytes; { // locking scope XMLMutexLock lockConverter(&fConverter->fMutex); retCode = uniconv(fConverter->fIconv390DescriptorTo, &tmpInPtr, &inByteLeft, &tmpOutPtr, &outByteLeft); } if ( (retCode < 0) && (errno != E2BIG) ) { return 0; } // Give back the counts of eaten and transcoded charsEaten = srcCount-inByteLeft/sizeof(XMLCh); return maxBytes-outByteLeft;}bool Uniconv390Transcoder::canTranscodeTo(const unsigned int toCheck) const{ int retCode;DBGPRINTF1("Uniconv390Transcoder::canTranscodeTo\n");//printf("!!!***Uniconv390Transcoder::canTranscodeTo\n"); // // If the passed value is really a surrogate embedded together, then // we need to break it out into its two chars. Else just one. While // we are ate it, convert them to UChar format if required. // XMLCh srcBuf[2]; unsigned int srcCount = 1; if (toCheck & 0xFFFF0000) { srcBuf[0] = XMLCh((toCheck >> 10) + 0xD800); srcBuf[1] = XMLCh(toCheck & 0x3FF) + 0xDC00;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -