[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/samples codepage.cs,1.3,1.4
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/samples codepage.cs,1.3,1.4 |
Date: |
Sat, 16 Aug 2003 01:27:25 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/samples
In directory subversions:/tmp/cvs-serv15300/samples
Modified Files:
codepage.cs
Log Message:
Add -u and -c options to codepage that can dump code pages
in UCM or reverse-UCM form.
Index: codepage.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/samples/codepage.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** codepage.cs 16 Aug 2003 01:01:17 -0000 1.3
--- codepage.cs 16 Aug 2003 05:27:23 -0000 1.4
***************
*** 19,22 ****
--- 19,28 ----
// ilrun codepage.exe -u name
// -- Dump mappings from Unicode to web encoding "name".
+ //
+ // ilrun codepage.exe -c nnn
+ // -- Dump mappings from code page "nnn" to Unicode.
+ //
+ // ilrun codepage.exe -c name
+ // -- Dump mappings from web encoding "name" to Unicode.
using System;
***************
*** 100,108 ****
}
! private static String hexchars = "0123456789abcdef";
// Dump a value in hexadecimal.
private static void DumpHex(int value, int numDigits)
{
int shift = (numDigits * 4) - 4;
while(shift >= 0)
--- 106,125 ----
}
! private static String hexcharsLower = "0123456789abcdef";
! private static String hexcharsUpper = "0123456789ABCDEF";
// Dump a value in hexadecimal.
private static void DumpHex(int value, int numDigits)
{
+ String hexchars;
+ if(numDigits >= 0)
+ {
+ hexchars = hexcharsLower;
+ }
+ else
+ {
+ hexchars = hexcharsUpper;
+ numDigits = -numDigits;
+ }
int shift = (numDigits * 4) - 4;
while(shift >= 0)
***************
*** 190,198 ****
// Dump the Unicode character mappings for an encoding.
! private static void DumpEncoding(Encoding enc)
{
byte[] buf = new byte [enc.GetMaxByteCount(1)];
char[] chars = new char [1];
! int value, numBytes, index;
for(value = 0; value < 65536; ++value)
{
--- 207,219 ----
// Dump the Unicode character mappings for an encoding.
! private static void DumpEncoding(Encoding enc, bool fromCodePage)
{
byte[] buf = new byte [enc.GetMaxByteCount(1)];
char[] chars = new char [1];
! ushort[] usage = new ushort [65535];
! int value, numBytes, index, codeValue;
! Console.WriteLine("# Code page {0} - {1}",
! enc.CodePage,
enc.EncodingName);
! Console.WriteLine();
for(value = 0; value < 65536; ++value)
{
***************
*** 213,224 ****
(numBytes != 1 || buf[0] != (byte)'?' || value ==
(int)'?'))
{
! DumpHex(value, 4);
! Console.Write(':');
! for(index = 0; index < numBytes; ++index)
{
! Console.Write(' ');
! DumpHex(buf[index], 2);
}
- Console.WriteLine();
}
}
--- 234,269 ----
(numBytes != 1 || buf[0] != (byte)'?' || value ==
(int)'?'))
{
! if(fromCodePage)
{
! Console.Write("0x");
! for(index = 0; index < numBytes;
++index)
! {
! DumpHex(buf[index], -2);
! }
! Console.Write(" 0x");
! DumpHex(value, -4);
! Console.WriteLine();
! }
! else
! {
! Console.Write("<U");
! DumpHex(value, -4);
! Console.Write("> \\x");
! codeValue = 0;
! for(index = 0; index < numBytes;
++index)
! {
! codeValue = (codeValue << 8) +
buf[index];
! DumpHex(buf[index], -2);
! }
! if(codeValue < 0x10000)
! {
! Console.WriteLine(" |{0}",
usage[codeValue]);
! ++(usage[codeValue]);
! }
! else
! {
! Console.WriteLine();
! }
}
}
}
***************
*** 282,286 ****
// Dump Unicodoe mappings for a specific code page.
! private static void DumpPage(int page)
{
Encoding enc;
--- 327,331 ----
// Dump Unicodoe mappings for a specific code page.
! private static void DumpPage(int page, bool fromCodePage)
{
Encoding enc;
***************
*** 299,303 ****
if(enc != null)
{
! DumpEncoding(enc);
}
else
--- 344,348 ----
if(enc != null)
{
! DumpEncoding(enc, fromCodePage);
}
else
***************
*** 309,313 ****
// Dump Unicode mappings for a specific web encoding.
! private static void DumpWebEncoding(String name)
{
Encoding enc;
--- 354,358 ----
// Dump Unicode mappings for a specific web encoding.
! private static void DumpWebEncoding(String name, bool fromCodePage)
{
Encoding enc;
***************
*** 326,330 ****
if(enc != null)
{
! DumpEncoding(enc);
}
else
--- 371,375 ----
if(enc != null)
{
! DumpEncoding(enc, fromCodePage);
}
else
***************
*** 347,355 ****
if(args[1][0] >= '0' && args[1][0] <= '9')
{
! DumpPage(Int32.Parse(args[1]));
}
else
{
! DumpWebEncoding(args[1]);
}
}
--- 392,411 ----
if(args[1][0] >= '0' && args[1][0] <= '9')
{
! DumpPage(Int32.Parse(args[1]), false);
! }
! else
! {
! DumpWebEncoding(args[1], false);
! }
! }
! else if(args[0] == "-c" && args.Length > 1)
! {
! if(args[1][0] >= '0' && args[1][0] <= '9')
! {
! DumpPage(Int32.Parse(args[1]), true);
}
else
{
! DumpWebEncoding(args[1], true);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/samples codepage.cs,1.3,1.4,
Rhys Weatherley <address@hidden> <=