sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\plugins\hex\hex.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: inline TUint8 NibbleToHex(TUint8 aNibble) sl@0: { sl@0: return (TUint8) ((aNibble > 9) ? 'A' + aNibble - 10 : '0' + aNibble); sl@0: } sl@0: sl@0: inline TUint8 HexToNibble(TUint8 aHexChar) sl@0: { sl@0: return (TUint8) ((aHexChar > '9') ? aHexChar - 'A' + 10: aHexChar - '0'); sl@0: } sl@0: sl@0: void Hex(TDes8& aSrcBuffer, TDes8& aDstBuffer) sl@0: { sl@0: TInt len = aSrcBuffer.Length(); sl@0: aDstBuffer.SetLength(len << 1); sl@0: for (TInt n=0; n> 4); sl@0: aDstBuffer[n<<1] = NibbleToHex(nibble); sl@0: nibble = (TUint8) (b & 0x0F); sl@0: aDstBuffer[(n<<1)+1] = NibbleToHex(nibble); sl@0: } sl@0: } sl@0: sl@0: void DeHex(TDes8& aSrcBuffer, TDes8& aDstBuffer) sl@0: { sl@0: TInt len = aSrcBuffer.Length(); sl@0: aDstBuffer.SetLength(len >> 1); sl@0: for (TInt n=0; n>1] = (TUint8) ((hiNibble << 4) + loNibble); sl@0: } sl@0: }