Skip to content

Commit c42d5bf

Browse files
committed
unicode support for windows wrappers
1 parent 8664c2c commit c42d5bf

File tree

2 files changed

+55
-39
lines changed

2 files changed

+55
-39
lines changed

Wurstpack/wurstscript/grill.cmd

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
@echo off
2-
setlocal EnableExtensions
2+
setlocal
33

4-
rem ---- shared slim runtime ----
5-
set "RUNTIME=%USERPROFILE%\.wurst\wurst-runtime\bin\java.exe"
4+
rem Save current code page
5+
for /f "tokens=2 delims=: " %%A in ('chcp') do set "_OLDCP=%%A"
66

7-
rem script directory (trailing backslash)
7+
rem Switch to UTF-8 for this session
8+
chcp 65001 >NUL
9+
10+
rem Resolve script dir
811
set "DIR=%~dp0"
912

10-
if not exist "%RUNTIME%" (
11-
echo [wurstscript] ERROR: Runtime not found:
12-
echo(%RUNTIME%
13-
echo Reinstall Wurstscript via the VSCode extension.
14-
exit /b 1
13+
set "JAVA=%DIR%wurst-runtime\bin\java.exe"
14+
set "GRILL_JAR=%DIR%grill\grill.jar"
15+
16+
if not exist "%GRILL_JAR%" (
17+
echo [grill] ERROR: Missing jar. Searched:
18+
echo %GRILL_JAR%
19+
rem fallback to ../grill if you want:
20+
set "GRILL_JAR=%DIR%..\grill\grill.jar"
21+
if not exist "%GRILL_JAR%" (
22+
echo %GRILL_JAR%
23+
goto :restore
24+
)
1525
)
1626

17-
rem ---- fixed jar location(s), no wildcards ----
18-
set "JAR=%DIR%grill\grill.jar"
19-
if not exist "%JAR%" set "JAR=%DIR%..\grill\grill.jar"
20-
if not exist "%JAR%" (
21-
echo [grill] ERROR: Missing jar:
22-
echo(%DIR%grill\grill.jar
23-
echo or
24-
echo(%DIR%..\grill\grill.jar
25-
exit /b 1
27+
if not exist "%JAVA%" (
28+
echo [grill] ERROR: Bundled runtime not found or not executable at:
29+
echo %JAVA%
30+
echo Please reinstall wurstscript via the VS Code extension.
31+
goto :restore
2632
)
2733

28-
rem Optional JVM flags via env var, e.g. set WURST_JAVA_OPTS=-Xmx1g
29-
"%RUNTIME%" %WURST_JAVA_OPTS% -jar "%JAR%" %*
34+
"%JAVA%" -Dfile.encoding=UTF-8 -jar "%GRILL_JAR%" %*
35+
36+
:restore
37+
rem Restore previous code page if we captured it
38+
if defined _OLDCP chcp %_OLDCP% >NUL
39+
3040
endlocal
Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
@echo off
2-
setlocal EnableExtensions
2+
setlocal
33

4-
rem ---- shared slim runtime ----
5-
set "RUNTIME=%USERPROFILE%\.wurst\wurst-runtime\bin\java.exe"
4+
rem Save current code page
5+
for /f "tokens=2 delims=: " %%A in ('chcp') do set "_OLDCP=%%A"
6+
7+
rem Switch to UTF-8
8+
chcp 65001 >NUL
69

7-
rem script directory (trailing backslash)
810
set "DIR=%~dp0"
11+
set "JAVA=%DIR%wurst-runtime\bin\java.exe"
12+
set "JAR=%DIR%wurst-compiler\wurstscript.jar"
913

10-
if not exist "%RUNTIME%" (
11-
echo [wurstscript] ERROR: Runtime not found:
12-
echo(%RUNTIME%
13-
echo Reinstall Wurstscript via the VSCode extension.
14-
exit /b 1
14+
if not exist "%JAR%" (
15+
set "JAR=%DIR%..\wurst-compiler\wurstscript.jar"
1516
)
1617

17-
rem ---- fixed jar location(s), no wildcards ----
18-
set "JAR=%DIR%wurst-compiler\wurstscript.jar"
19-
if not exist "%JAR%" set "JAR=%DIR%..\wurst-compiler\wurstscript.jar"
2018
if not exist "%JAR%" (
21-
echo [wurstscript] ERROR: Missing jar:
22-
echo(%DIR%wurst-compiler\wurstscript.jar
23-
echo or
24-
echo(%DIR%..\wurst-compiler\wurstscript.jar
25-
exit /b 1
19+
echo [wurstscript] ERROR: Missing jar. Searched:
20+
echo %DIR%wurst-compiler\wurstscript.jar
21+
echo %DIR%..\wurst-compiler\wurstscript.jar
22+
goto :restore
2623
)
2724

28-
rem Optional JVM flags via env var, e.g. set WURST_JAVA_OPTS=-Xmx1g
29-
"%RUNTIME%" %WURST_JAVA_OPTS% -jar "%JAR%" %*
25+
if not exist "%JAVA%" (
26+
echo [wurstscript] ERROR: Bundled runtime not found or not executable at:
27+
echo %JAVA%
28+
echo Please reinstall wurstscript via the VS Code extension.
29+
goto :restore
30+
)
31+
32+
"%JAVA%" -Dfile.encoding=UTF-8 -jar "%JAR%" %*
33+
34+
:restore
35+
if defined _OLDCP chcp %_OLDCP% >NUL
3036
endlocal

0 commit comments

Comments
 (0)