diff --git a/src/nimble.nim b/src/nimble.nim index d609010..bd5d385 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -519,7 +519,11 @@ proc installFromDir(dir: string, latest: bool, options: TOptions, elif defined(windows): let dest = binDir / cleanBin.changeFileExt("bat") echo("Creating stub: ", pkgDestDir / bin, " -> ", dest) - writeFile(dest, "\"" & pkgDestDir / bin & "\" %*\n") + var contents = "" + if options.config.chcp: + contents.add "chcp 65001\n" + contents.add "\"" & pkgDestDir / bin & "\" %*\n" + writeFile(dest, contents) else: {.error: "Sorry, your platform is not supported.".} else: diff --git a/src/nimblepkg/config.nim b/src/nimblepkg/config.nim index 751a071..bb9a172 100644 --- a/src/nimblepkg/config.nim +++ b/src/nimblepkg/config.nim @@ -7,6 +7,7 @@ import tools, version type TConfig* = object nimbleDir*: string + chcp*: bool # Whether to change the code page in .cmd files on Win. proc initConfig(): TConfig = if getNimrodVersion() > newVersion("0.9.6"): @@ -14,6 +15,8 @@ proc initConfig(): TConfig = else: result.nimbleDir = getHomeDir() / ".babel" + result.chcp = true + proc parseConfig*(): TConfig = result = initConfig() var confFile = getConfigDir() / "nimble" / "nimble.ini" @@ -42,6 +45,8 @@ proc parseConfig*(): TConfig = # Ensure we don't restore the deprecated nimble dir. if e.value != getHomeDir() / ".babel": result.nimbleDir = e.value + of "chcp": + result.chcp = parseBool(e.value) else: raise newException(ENimble, "Unable to parse config file:" & " Unknown key: " & e.key)