WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Unicode

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WinExist and Double-byte Characters

 Keywords: WinExist Double Byte Characters Set DBCS Foreign Chinese Japanese 

Question:

I am wondering if the WinExist function should support double byte characters. I'm trying to build an package that searches for a Window with a Chinese title.

Answer:

Yes WinExist supports double-byte character sets. Like most WinBatch functions WinExist converts string input to Unicode UTF-16 on all currently supported systems. By default the conversion is performed using the current system ANSI code page. If your system happens to be set to the correct Chinese ANSI code page, the conversion will work and any existing window should be found. However, if your system's default code page is something other than a Chinese one, you will have difficulty finding the window.

There are two workarounds you might want to consider, if you system is not defaulted to a Chinese code page. You could try telling WinBatch to temporarily use a Chinese code page like 950 or 936 by using the ChrGetCodePage and ChrSetCodePage functions for your call to WinExist. These code pages would need to be available on your system for this approach to work.

The other approach would be to convert the window title to Unicode before passing it to WinExist. There are several ways to do the conversion with both the ChrHexToUnicode or BinaryConvert functions coming to mind as possible approaches but there are other techniques. ChrHexToUnicode is probably the easiest if you can assume your window name or names is or are not going to change frequently.


Article ID:   W18423
Filename:   WinExist and Double-byte Characters.txt
File Created: 2013:07:29:11:58:16
Last Updated: 2013:07:29:11:58:16