From f16140fc9599e3c12a3dfe912cac1819c04174d7 Mon Sep 17 00:00:00 2001 From: miere43 Date: Sat, 30 Jul 2016 18:25:48 +0300 Subject: [PATCH 1/2] fix #4417, update news --- compiler/commands.nim | 9 +++++++++ lib/system.nim | 5 +++++ web/news/version_0_15_released.rst | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/commands.nim b/compiler/commands.nim index 48926f6026..de1197292c 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -217,6 +217,15 @@ proc testCompileOptionArg*(switch, arg: string, info: TLineInfo): bool = of "none": result = gOptions * {optOptimizeSpeed, optOptimizeSize} == {} else: localError(info, errNoneSpeedOrSizeExpectedButXFound, arg) of "verbosity": result = $gVerbosity == arg + of "app": + case arg.normalize + of "gui": result = contains(gGlobalOptions, optGenGuiApp) + of "console": result = not contains(gGlobalOptions, optGenGuiApp) + of "lib": result = contains(gGlobalOptions, optGenDynLib) and + not contains(gGlobalOptions, optGenGuiApp) + of "staticlib": result = contains(gGlobalOptions, optGenStaticLib) and + not contains(gGlobalOptions, optGenGuiApp) + else: localError(info, errGuiConsoleOrLibExpectedButXFound, arg) else: invalidCmdLineOption(passCmd1, switch, info) proc testCompileOption*(switch: string, info: TLineInfo): bool = diff --git a/lib/system.nim b/lib/system.nim index 6a9b52d241..0c2cc24667 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3670,3 +3670,8 @@ template closureScope*(body: untyped): untyped = when defined(nimconfig): include "system/nimscript" + +when defined(windows) and compileOption("app", "console"): + proc setConsoleOutputCP(codepage: cint): cint {.stdcall, dynlib: "kernel32", + importc: "SetConsoleOutputCP".} + discard setConsoleOutputCP(65001) # 65001 - utf-8 codepage \ No newline at end of file diff --git a/web/news/version_0_15_released.rst b/web/news/version_0_15_released.rst index b9c9bc50bd..1e35fb627f 100644 --- a/web/news/version_0_15_released.rst +++ b/web/news/version_0_15_released.rst @@ -26,7 +26,7 @@ Changes affecting backwards compatibility Warning: a [b] will be parsed as command syntax; spacing is deprecated - See `https://github.com/nim-lang/Nim/issues/3898`_ for the relevant + See ``_ for the relevant discussion. - Overloading the special operators ``.``, ``.()``, ``.=``, ``()`` now should be enabled via ``{.experimental.}``. @@ -52,6 +52,8 @@ that have tuple name: var rocketaims = initOrderedTable[string, Table[tuple[k: int8, v: int8], int64] ]() rocketaims["hi"] = {(k: -1.int8, v: 0.int8): 0.int64}.toTable() +- Now when you compile console application for Windows, console output + encoding is automatically set to UTF-8. Library Additions ----------------- From 70ea30d492ce038ae36dcceffece09c0b074721c Mon Sep 17 00:00:00 2001 From: miere43 Date: Sat, 30 Jul 2016 20:28:43 +0300 Subject: [PATCH 2/2] use appType instead of compileOption #4417 --- lib/system.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system.nim b/lib/system.nim index 0c2cc24667..c2b45e01de 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3671,7 +3671,7 @@ template closureScope*(body: untyped): untyped = when defined(nimconfig): include "system/nimscript" -when defined(windows) and compileOption("app", "console"): +when defined(windows) and appType == "console": proc setConsoleOutputCP(codepage: cint): cint {.stdcall, dynlib: "kernel32", importc: "SetConsoleOutputCP".} discard setConsoleOutputCP(65001) # 65001 - utf-8 codepage \ No newline at end of file