crashanalysercmd/Libraries/File Formats/Plugins/CrashXmlPlugin/FileFormat/Utiltities/Utilities.cs
equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Text; |
|
19 using System.Collections.Generic; |
|
20 using System.Xml; |
|
21 |
|
22 namespace CrashXmlPlugin.FileFormat |
|
23 { |
|
24 internal static class Utilities |
|
25 { |
|
26 public static string[] ConvertBinaryDataToText( IEnumerable<byte> aData, int aLineLength ) |
|
27 { |
|
28 List<string> lines = new List<string>(); |
|
29 |
|
30 StringBuilder line = new StringBuilder(); |
|
31 foreach ( byte b in aData ) |
|
32 { |
|
33 line.AppendFormat( "{0:x2}", b ); |
|
34 |
|
35 if ( line.Length >= aLineLength ) |
|
36 { |
|
37 lines.Add( line.ToString() ); |
|
38 line.Length = 0; |
|
39 } |
|
40 } |
|
41 |
|
42 // Flush leftovers |
|
43 if ( line.Length > 0 ) |
|
44 { |
|
45 lines.Add( line.ToString() ); |
|
46 } |
|
47 |
|
48 return lines.ToArray(); |
|
49 } |
|
50 } |
|
51 } |