740 //if seeking and reading both succesful extract one line form the buffer |
740 //if seeking and reading both succesful extract one line form the buffer |
741 if (result == KErrNone) |
741 if (result == KErrNone) |
742 { |
742 { |
743 TPtrC8 ptrBuf8; |
743 TPtrC8 ptrBuf8; |
744 ptrBuf8.Set( buf ); |
744 ptrBuf8.Set( buf ); |
745 |
745 |
746 if (result == KErrNone || result == KErrEof) |
746 switch ( iCharSet ) |
747 { |
747 { |
748 switch ( iCharSet ) |
748 case ECharSetUnicode: |
749 { |
749 { |
750 case ECharSetUnicode: |
750 //simply copy to a Unicode descriptor |
751 { |
751 TPtrC16 ptrBuf16( ( TText16* )ptrBuf8.Ptr(), \ |
752 //simply copy to a Unicode descriptor |
752 ptrBuf8.Length() / KAsciiUnicodeRatio ); |
753 TPtrC16 ptrBuf16( ( TText16* )ptrBuf8.Ptr(), \ |
|
754 ptrBuf8.Length() / KAsciiUnicodeRatio ); |
|
755 |
753 |
756 TPtrC16 ptrLine; |
754 TPtrC16 ptrLine; |
757 result = ExtractLine(ptrBuf16, ptrLine); |
755 result = ExtractLine(ptrBuf16, ptrLine); |
758 |
756 |
759 if ( result == KErrNone ) |
757 if ( result == KErrNone ) |
760 { |
758 { |
761 delete iLine; |
759 delete iLine; |
762 iLine = NULL; |
760 iLine = NULL; |
763 iLine = ptrLine.AllocL(); |
761 iLine = ptrLine.AllocL(); |
|
762 |
|
763 //Increment the file position |
|
764 iFilePos += iLine->Length() * KAsciiUnicodeRatio; |
|
765 } |
|
766 |
|
767 break; |
|
768 } |
|
769 case ECharSetAscii: |
|
770 case ECharSetUtf8: |
|
771 default: |
|
772 { |
|
773 //conversion to Unicode is needed |
|
774 HBufC16* hBuf16 = HBufC16::NewLC( KMaxLineSize ); |
|
775 TPtr16 ptrBuf16( hBuf16->Des() ); |
|
776 |
|
777 if( iCharSet == ECharSetUtf8 ) |
|
778 { |
|
779 CnvUtfConverter::ConvertToUnicodeFromUtf8 |
|
780 ( ptrBuf16, ptrBuf8 ); |
|
781 } |
|
782 else |
|
783 { |
|
784 ptrBuf16.Copy( ptrBuf8 ); |
|
785 } |
|
786 |
|
787 TPtrC16 ptrLine; |
|
788 result = ExtractLine(ptrBuf16, ptrLine); |
|
789 |
|
790 if ( result == KErrNone ) |
|
791 { |
|
792 delete iLine; |
|
793 iLine = NULL; |
|
794 iLine = ptrLine.AllocL(); |
764 |
795 |
765 //Increment the file position |
796 // Increment the file position |
766 iFilePos += iLine->Length() * KAsciiUnicodeRatio; |
797 // Line in unicode format converted back to UTF-8 |
767 } |
798 // for getting the right lenght and osition in file |
|
799 CnvUtfConverter::ConvertFromUnicodeToUtf8( |
|
800 buf, iLine->Des() ); |
|
801 iFilePos += buf.Length(); |
|
802 } |
768 |
803 |
769 break; |
804 CleanupStack::PopAndDestroy( hBuf16 ); |
770 } |
|
771 case ECharSetAscii: |
|
772 case ECharSetUtf8: |
|
773 default: |
|
774 { |
|
775 //conversion to Unicode is needed |
|
776 HBufC16* hBuf16 = HBufC16::NewLC( KMaxLineSize ); |
|
777 TPtr16 ptrBuf16( hBuf16->Des() ); |
|
778 |
805 |
779 if( iCharSet == ECharSetUtf8 ) |
806 break; |
780 { |
807 }//case |
781 CnvUtfConverter::ConvertToUnicodeFromUtf8 |
808 }//switch |
782 ( ptrBuf16, ptrBuf8 ); |
|
783 } |
|
784 else |
|
785 { |
|
786 ptrBuf16.Copy( ptrBuf8 ); |
|
787 } |
|
788 |
|
789 TPtrC16 ptrLine; |
|
790 result = ExtractLine(ptrBuf16, ptrLine); |
|
791 |
|
792 if ( result == KErrNone ) |
|
793 { |
|
794 delete iLine; |
|
795 iLine = NULL; |
|
796 iLine = ptrLine.AllocL(); |
|
797 |
|
798 // Increment the file position |
|
799 // Line in unicode format converted back to UTF-8 |
|
800 // for getting the right lenght and osition in file |
|
801 CnvUtfConverter::ConvertFromUnicodeToUtf8( |
|
802 buf, iLine->Des() ); |
|
803 iFilePos += buf.Length(); |
|
804 } |
|
805 |
|
806 CleanupStack::PopAndDestroy( hBuf16 ); |
|
807 |
|
808 break; |
|
809 }//case |
|
810 }//switch |
|
811 }//if |
|
812 }//if |
809 }//if |
813 |
810 |
814 return result; |
811 return result; |
815 } |
812 } |
816 |
813 |