From 54fb8faee1e3293946725baf669090825b649f3c Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Tue, 1 Nov 2005 16:21:40 +0000 Subject: [PATCH] Handle extended ascii and double byte in GUI. --- c_sharp/NSSCSWrapper/NativeCalls.cs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/c_sharp/NSSCSWrapper/NativeCalls.cs b/c_sharp/NSSCSWrapper/NativeCalls.cs index 64f2db38..e720a508 100644 --- a/c_sharp/NSSCSWrapper/NativeCalls.cs +++ b/c_sharp/NSSCSWrapper/NativeCalls.cs @@ -587,12 +587,29 @@ namespace Novell.CASA else { if (iKeyLen > 1) - sKey = Marshal.PtrToStringAnsi(theKey, (int)iKeyLen - 1); + { + //sKey = Marshal.PtrToStringAnsi(theKey, (int)iKeyLen - 1); + // convert from UTF8 + byte[] baKey = new byte[iKeyLen-1]; + Marshal.Copy(theKey, baKey, 0, (int)iKeyLen-1); + sKey = System.Text.Encoding.UTF8.GetString(baKey, 0, baKey.Length); + } + if (iValueLen > 1) - sValue = Marshal.PtrToStringAnsi(theValue, (int)iValueLen -1); - - secret.setKeyValuePair(sKey, sValue); + { + //sValue = Marshal.PtrToStringAnsi(theValue, (int)iValueLen -1); + + // convert from UTF8 + byte[] baValue = new byte[iValueLen-1]; + Marshal.Copy(theValue, baValue, 0, (int)iValueLen-1); + sValue = System.Text.Encoding.UTF8.GetString(baValue, 0, baValue.Length); + } + + if (sKey != null && sValue != null) + secret.setKeyValuePair(sKey, sValue); + + iStart = 0; } @@ -720,7 +737,7 @@ namespace Novell.CASA internal bool KeyInNewList(NameValueCollection nvc, string key) { - Console.WriteLine("Checking for " + key ); + //Console.WriteLine("Checking for " + key ); if (nvc != null) { for (int i = 0; i < nvc.Count; i++)