Changeset 8 for trunk/src/codecs
- Timestamp:
- Nov 16, 2005, 8:36:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/codecs/qtextcodec.cpp
r7 r8 562 562 563 563 564 #if def Q_OS_WIN32564 #if defined(Q_OS_WIN32) 565 565 class QWindowsLocalCodec: public QTextCodec 566 566 { … … 621 621 622 622 int QWindowsLocalCodec::heuristicContentMatch(const char* chars, int len) const 623 { 624 // ### Not a bad default implementation? 625 QString t = toUnicode(chars,len); 626 int l = t.length(); 627 QCString mb = fromUnicode(t,l); 628 int i=0; 629 while ( i < len ) { 630 if ( chars[i] == mb[i] ) 631 i++; 632 else 633 break; 634 } 635 return i; 636 } 637 638 #elif defined(Q_OS_OS2) 639 640 class QOS2LocalCodec: public QTextCodec 641 { 642 public: 643 QOS2LocalCodec(); 644 ~QOS2LocalCodec(); 645 646 QString toUnicode(const char* chars, int len) const; 647 QCString fromUnicode(const QString& uc, int& lenInOut ) const; 648 649 const char* name() const; 650 int mibEnum() const; 651 652 int heuristicContentMatch(const char* chars, int len) const; 653 }; 654 655 QOS2LocalCodec::QOS2LocalCodec() 656 { 657 } 658 659 QOS2LocalCodec::~QOS2LocalCodec() 660 { 661 } 662 663 664 QString QOS2LocalCodec::toUnicode(const char* chars, int len) const 665 { 666 return qt_os2MB2QString( chars, len ); 667 } 668 669 QCString QOS2LocalCodec::fromUnicode(const QString& uc, int& lenInOut ) const 670 { 671 QCString r = qt_os2QString2MB( uc, lenInOut ); 672 lenInOut = r.length(); 673 return r; 674 } 675 676 677 const char* QOS2LocalCodec::name() const 678 { 679 return "System"; 680 } 681 682 int QOS2LocalCodec::mibEnum() const 683 { 684 return 0; 685 } 686 687 688 int QOS2LocalCodec::heuristicContentMatch(const char* chars, int len) const 623 689 { 624 690 // ### Not a bad default implementation? … … 2692 2758 static void setupLocaleMapper() 2693 2759 { 2694 #if def Q_OS_WIN322760 #if defined(Q_OS_WIN32) || defined(Q_OS_OS2) 2695 2761 localeMapper = QTextCodec::codecForName( "System" ); 2696 2762 #else … … 2855 2921 #endif // Q_OS_WIN32 2856 2922 2923 #ifdef Q_OS_OS2 2924 (void) new QOS2LocalCodec; 2925 #endif // Q_OS_OS2 2926 2857 2927 if ( !localeMapper ) 2858 2928 setupLocaleMapper();
Note:
See TracChangeset
for help on using the changeset viewer.