MultiByte character problem



  • 1. General profile
    Hi, Is there a profile that everyone executes besides their own? similiar to /etc/profile I would like new users to have specific functions and variables setup. Thanks,
  • 2. Sorting an array on pattern?
    Hi, Given a textfile (read into an array) with some entries including a date and some don't. I want to sort this array with date-entries first (newest dates first) and then the rest of the entries sorted normally (by content) The date is identified by "d:" E.g. text in line some text here d:2007-05-04 some text here d:2007-06-01 more text even more text some text here d:2007-05-24 this is a line some text here d:2007-06-04 I would like this to be: text here d:2007-06-04 some text here d:2007-06-01 some text here d:2007-05-24 some text here d:2007-05-04 even more text more text text in line this is a line some I have splitted the original array into two new ones (one with dates and the other with the rest of the lines). $lines = gc <original file> $dates, $lines = $lines | %{if($_ -match "d:[0-9\-]{6,}") {$_}else{$_}} But I haven't figured out the easiest way to sort on the date pattern. Anyone?
  • 3. Signing Powershell Scripts with Microsoft Certificate Authorit
    So once I have the cert, do I put it in the Trusted Certs folder? -- Sandy Wood Orange County District Attorney "Neil Chambers" wrote: > On 2007-06-04 19:09:03 +0100, Sandy Wood < XXXX@XXXXX.COM > said: > > > I'd like to sign my Powershell scripts and we have a Microsoft > > Certificate Authority root server in our AD domain. Doesn't this mean > > that all domain systems have the root certificate automatically > > installed on them? > > > > That said, I'd like to sign my scripts, somehow, with this script. Most > > of the information on certs for Powershell code focus on the steps for > > a self-created cert. I'm having a problem applying the steps to a cert > > that is created by our own server. Has anyone done this? > > I'm not up to speed on MS Certificate Authority so I can't say if your > clients will have the RootCA Cert. > > As for getting a certificate - you need to create a request using the > Certificates MMC snap-in (you will be prompted as to whether you want a > cert for your user id or the machine). Make sure the request type is > for code signing. Send the request to the MS RootCA admin and get them > to sign it and send the completed certificate back. Once imported on > your keychain you should be good to go. > > n > >

MultiByte character problem

Postby QW5kcmV3 » Wed, 27 May 2009 18:54:01 GMT

I use get-content xxx.txt to get the content.
It is encoded in utf8,with many multi-byte chars.

the problem is:
the mult-byte chars are printed as ???? like things.

how can i get it work correctly?

Re: MultiByte character problem

Postby Vadims Podans [MVP] » Thu, 28 May 2009 02:16:09 GMT

IIUC, you should use -Encoding parameter with Get-Content cmdlet.
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog -

"Andrew" < XXXX@XXXXX.COM > rakstja ziojum 

Similar Threads:

1.Problem with "multibyte or wide character"

2.0xC000005 - Access Violation when trying to save some MultiByte characters to a file by using fwrite

Feel like a dog, I tried everything but couldn't get rid of that error
I refer in subject... :-(

This part of my code should save the content of editbox to a file
(characters need to be saved in multibyte).

void SaveInMultiByte(void)
	FILE *stream;
	LPTSTR lpStringInEdit;
	long int StringLength;
	char* CharForSave;
	int numwritten;
	int a;

	StringLength = GetWindowTextLength(hWndMainEditBox)+1;
	lpStringInEdit = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, StringLength
	MultibyteStringForSave = (char*)malloc(StringLength+10);
	GetWindowText(hWndMainEditBox, lpStringInEdit, StringLength+10);

	wcstombs(MultibyteStringForSave, lpStringInEdit, StringLength);

	if((stream = _wfopen(szFileName, L"wb")) == NULL){
		MessageBox(g_hWnd, TEXT("File couldn't be saved."), TEXT("File
error"), MB_ICONERROR);

	numwritten = fwrite(MultibyteStringForSave, sizeof(char),
StringLength - 1, stream);      // here I get that access violation


	HeapFree(GetProcessHeap(), 0, lpStringInEdit);


What did I make wrong there?

The strange thing is that I've been getting that error also with
calling the funcs malloc and HeapAlloc approximately 6 hours ago.
After when I get rid of that error by calling funcs malloc and
HeapAlloc it just starts appearing by calling the func fwrite and I
couldn't resolve ths problem out to this moment:-(

I will appreciate any tips.

Thanks in advance.

3.WinAPI Multibyte/Unicode problem

Hi all,
I have a little problem in my application. When I compile it with 
UNICODE character set, i don't have small icons in my listview items 
anymore. But if i build it with Multibyte character set, i have theese 
icons. Someone knows how to correct this? Thanks!


4.Ansi vs Multibyte Name Checking

We have a client requesting that we change our name checking method from the 
default of Multibyte (UTF8) to Strict RFC (Ansi).  Their firewall is 
rejecting our web page as being Non Compliant.

I know how to do this but I am not sure this is something I should do for 
this client. What are the ramifications if I do this?  Is it any kind of 
security problem the way it is currently, Multibyte?

We are having no problems with anyone else in several years so i am hesitant 
to change for 1 client who might just be Anti MS for some reason.

Any Opinions or Ideas?

5.MultiByte strings in the OAL (KERN.EXE)

I am trying to write a REG_SZ registry value in my OALIoCtlHalInitRegistry() 
function, getting the value from an standard asciiz string passed up from 
the bootloader.

This was what I thought I'd do:

MultiByteToWideChar(CP_OEMCP, 0, pBoardInfo->serialNo, -1, Buffer, 
    if(Status == ERROR_SUCCESS)
      Status = NKRegSetValueEx (hKey, VALUE_SERIALNO, 0, REG_SZ, 
(PBYTE)&Buffer[0], (wcslen(Buffer) + 1) * sizeof(WCHAR));

However this gives me unresolved linker errors, I don't want to include the 
coredll.dll lib in my OAL, I dont think you can do that can you?

So I guess I need a quick and dirty routine to convert an asciiz string to 
multibyte, any clues anyone?

6. Multibyte (Japanese) shares inaccessible from XP Home

7. IE 6 windows shows characters fuzzy, not clean lined characters

8. Change Auto-Replace character to Auto-Add Character

Return to powershell


Who is online

Users browsing this forum: No registered users and 58 guest