Skip to content

Commit 1c8243d

Browse files
committed
Adding UTF-8 support for WideCharToMultiByte method - Windows Platform hyperic#91
1 parent b156eaf commit 1c8243d

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

sigar_build.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Make sure to build in a new cmd environment if previously different architecture build was executed in the current cmd to reset the environment variable to default.
2+
3+
Use 64 bit machine with 64 bit Java (JAVA_HOME) for win64
4+
5+
1) Initialize Visual Studio Environment in command prompt:
6+
Win32 : "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
7+
Uncomment the commented statements in sigar_get_pointer() and sigar_set_pointer() @ sigar-1.6.4\bindings\java\src\jni\javasigar.c for Win32 build.
8+
9+
Win64 : "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"
10+
11+
2) Install cmake and Perl5 and add it's executables to PATH. Make sure you use Strawberry perl and not the perl present in unix scripts we use.
12+
13+
3) Set ANT build environment : ANT_HOME and add ANT_HOME/bin to PATH.
14+
15+
4)To build dll files directly :
16+
Go to sigar-1.6\bindings\java and run :
17+
a) ant clean
18+
b) ant
19+
OR
20+
4) For Visual Studio Solution file creation (note: do not use this as it creates sigar dll without java bindings):
21+
(To build Visual Studio Configuration files for 32 bit remove 'Win64' from @SET GENERATOR="Visual Studio 12 2013 Win64" in winbuild.bat)
22+
Run winbuild.bat
23+
Open sigar.sln file from same command prompt. Make sure Linker-Command Line does not has X86 set as architecture in additional options of any project.
24+
25+
Add wmi.cpp to sigar project
26+
In sigar project : C/C++ -> Advanced -> compile As -> Default
27+
28+
Run Clean - Build

src/os/win32/sigar_os.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@
7676
/* XXX: support CP_UTF8 ? */
7777

7878
#define SIGAR_A2W(lpa, lpw, bytes) \
79-
(lpw[0] = 0, MultiByteToWideChar(CP_ACP, 0, \
79+
(lpw[0] = 0, MultiByteToWideChar(CP_UTF8, 0, \
8080
lpa, -1, lpw, (bytes/sizeof(WCHAR))))
8181

8282
#define SIGAR_W2A(lpw, lpa, chars) \
83-
(lpa[0] = '\0', WideCharToMultiByte(CP_ACP, 0, \
83+
(lpa[0] = '\0', WideCharToMultiByte(CP_UTF8, 0, \
8484
lpw, -1, (LPSTR)lpa, chars, \
8585
NULL, NULL))
8686

0 commit comments

Comments
 (0)