Skip to content

Commit

Permalink
feat: allow force utf8 by IDEA_NODEJS_CONSOLE_FORCE_UTF8
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Aug 15, 2024
1 parent 17e25ce commit c6aa98c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/io/plugin/tsnode/execution/TsUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,14 @@ object TsUtil
}
}

fun envDataValueToBoolean(v: Any?): Boolean?
{
if (!isEmptyOrSpacesOrNull(v))
{
return v.toString().toBoolean()
}

return null
}

}
4 changes: 3 additions & 1 deletion src/io/plugin/tsnode/lib/cmd/NodeJSCommandLine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ object MyNodeCommandLineUtil
{
var charset = commandLine.charset.toString().lowercase()

val force_utf8 = TsUtil.envDataValueToBoolean(commandLine.environment.get("IDEA_NODEJS_CONSOLE_FORCE_UTF8"))

LOG.info("current commandLine.charset ${charset}")

charset = charset.lowercase()

if (true || charset == "x-windows-950" || charset == "x-windows-936" || charset == "gbk")
if (force_utf8 == true || charset == "x-windows-950" || charset == "x-windows-936" || charset == "gbk")
{
commandLine.withCharset(Charset.forName("UTF-8"))
}
Expand Down

0 comments on commit c6aa98c

Please sign in to comment.