VCSSL 3.4.52 Released: Enhanced Integration with External Programs and More

We have recently released the latest version of VCSSL: Ver. 3.4.52.
You can download it from the following page:

While the previous release mainly focused on compatibility with Java 24, this one introduces several functional improvements.

Let's take a look at the details!

- Table of Contents -

Slight Enhancements to External Program Integration Features

First, let us explain the main feature area that's been improved in this release: integration with external programs.

VCSSL provides a mechanism to run executable files developed in other programming languages (such as .exe, .out, etc.) and communicate with them through standard input/output, allowing for basic inter-process communication.

For more details on this functionality, please refer to the following page in our official documentation:

By leveraging this feature, for example, you can create a simple GUI input screen in VCSSL and connect it to your own C-language program, effectively turning it into a lightweight GUI tool.

However, please note that this is a primitive integration method based solely on standard input/output, so it's not suitable for building complex GUI applications that require tight and intricate integration. In such cases, it's generally better to use DLLs or similar mechanisms and access them from a language more suited for GUI development.

New Feature for Handling Garbled Text (Character Encoding Issues)

Now, let's get into the main improvements. This update includes several enhancements aimed at improving integration with external programs.

One such enhancement deals with character encoding issues, often referred to as "mojibake" (garbled text).

Garbled Text Often Becomes a Problem When Exchanging Text Between Programs

When exchanging text between multiple programs, garbled characters frequently become an issue. This usually occurs when the character encoding used by Program A to output text differs from the encoding expected by Program B when reading it.

For example, until fairly recently, many Japanese-language programs running on Windows defaulted to a character encoding called "CP932."

However, in recent years, there has been a growing shift toward "UTF-8", resulting in a mixed environment where CP932 and UTF-8 coexist, often leading to compatibility headaches.

Similar issues tend to occur in many countries where non-ASCII characters are commonly used.

In this article, we'll use Japanese-language programs as a representative example to illustrate the situation.

The Inconvenient Workarounds Previously Required When Garbled Text Occurred

By default, when VCSSL runs an external program, it treats the content of its standard input/output as being encoded in UTF-8.

As a result, if the external program (written in C, for example) uses CP932 or another encoding for its I/O, the following workarounds were previously needed -- each with its own drawbacks:

Now You Can Specify Character Encoding for External Program I/O Within the Script

To address this issue, the Process library used to run external programs has been enhanced. We've added the following functions:

setProcessInputEncoding( int processID, string inputEncoding )
Sets the character encoding used to send standard input to the external program.
setProcessOutputEncoding( int processID, string outputEncoding )
Sets the character encoding used to read standard output from the external program.
setProcessErrorEncoding( int processID, string errorEncoding )
Sets the character encoding used to read standard error output from the external program.

By using these functions, you can now easily adjust the character encoding within your script to match the target external program, making it much simpler to avoid garbled text issues.

Example Code (Download Available)

Here's a example code:


import File;
import Process;

// ----------------------------------------------------------------------
// A VCSSL program that runs example.exe and displays its standard output
// ----------------------------------------------------------------------

// Create a process for example.exe
// ("argA/B/C" are the arguments passed to the program)
string programPath = getFilePath("example.exe");
string processArgs[] = { programPath, "argA", "argB", "argC" };
int processID = newProcess(processArgs);

// Set character encodings for standard input/output/error
setProcessInputEncoding(processID, "CP932"); // or "UTF-8", etc.
setProcessOutputEncoding(processID, "CP932");
setProcessErrorEncoding(processID, "CP932");

// Start running example.exe
startProcess(processID);


// Event handler for receiving standard output
void onProcessOutput(int sourceProcessId, string text) {
    print(text); // Display the received text as-is
}

// Event handler for receiving standard error
void onProcessError(int sourceProcessId, string text) {
    print(text); // Display the received text as-is
}
code/c_and_vcssl_mojibake_example/ExampleExecution.vcssl

In this example, let's assume that the "example.exe" being executed above is a compiled version of the following C program:

This program outputs the Japanese message:

(means "Good morning! How are you?" in Japanese)

The VCSSL script then receives this output from example.exe and simply displays it in the console.

Here's what the output looks like:

The message above contains Japanese characters, which are multi-byte and cannot be represented in ASCII. Characters like these will appear garbled if the character encodings don't match properly between programs. Below is the result when we change the encoding specified in setProcessOutputEncoding() to "UTF-8" instead:

As you can see, the output is garbled.

* On the other hand, simple strings like "Hello, World!" -- which consist only of characters in the ASCII range -- usually don't cause garbling issues. That's because most modern encodings such as CP932 and UTF-8 are ASCII-compatible extensions, meaning they can all handle ASCII strings correctly.

By the way, we've packaged both the compiled "example.exe" and the VCSSL script into a downloadable sample:

Feel free to download it and try switching the encoding used in setProcessOutputEncoding() between "CP932" and "UTF-8" to see how the output becomes garbled or properly displayed depending on the setting.

Note: If you're running this on a system that isn't configured for Japanese, there's a good chance that Japanese characters won't display correctly, simply because the necessary fonts aren't installed.

In that case, you'll need to install a Japanese-capable font, such as the IPA/IPAex fonts and set it to Java Runtime Environment, or modify the C source code to use multibyte characters and encodings that are supported on your system.

Now You Can Detect the OS Type from Scripts

Next up is another feature that contributes to improved external program integration:
VCSSL can now detect the type of operating system it's running on.

OS Detection Is Often Needed When Running Scripts Across Multiple Platforms

As shown in the earlier example, we compiled a C program into an executable file named "example.exe", and then ran it from within a VCSSL script.

However, executable files with the ".exe" extension generally only work on Microsoft Windows® systems. (There are some workarounds to run them on other platforms, but they require special environments.)

So, if you want to create a tool using C + VCSSL that works not only on Windows but also on Linux, you'll need to run an alternative executable -- such as one compiled for Linux in the ".out" format.

New Built-in Constants "OS" and "OSVER" for OS Detection

To support such use cases, we've added two new constants to the "System" library (which is available without needing to import it):

OS
A string indicating the general type of operating system.
OSVER
A string indicating the general development version or kernel generation of the OS.
Note: This part can get a bit confusing -- for example, on Windows 11, the official OS name is "Windows 11," but that "11" is not the actual version number. The system version is still "10.0.***" in the Windows NT lineage, and another naming system like "25H2" is also used in consumer-facing contexts. On both Windows 10 and Windows 11, the value of "OSVER" will be "10.0".

Example Code

Here's a example snippet that demonstrates the new feature:

println(OS);

When run on Windows 11, it outputs:

Windows 11

And on Ubuntu 24.04 LTS (a popular Linux distribution):

Linux

While this doesn't give detailed environment info, it's enough to distinguish between Windows and Linux -- which can be quite helpful when building cross-platform tools.

For more specific system requirements -- like "Windows 10 or 11" or "Ubuntu 24 LTS or later" -- we recommend noting those conditions in your software's documentation.

Other Improvements, Compatibility Fixes, and Bug Fixes

This update also includes a few additional improvements and fixes. Here's a brief overview:

Adjusting Capitalization and Trimming Whitespace in Strings

The Text library now includes the following utility function:

This lets you apply small adjustments to string values. The behavior depends on the value passed in "mode":

UPPER_CASE
Converts all alphabetic characters to uppercase
LOWER_CASE
Converts all alphabetic characters to lowercase
TRIM
Removes leading/trailing whitespace and newline characters

Further Fixes for Network Drive Behavior on Java 24

In the previous update, we addressed a compatibility issue on Java 24 where paths on network drives would be resolved as UNC-style paths. (For details, see the article below:)

However, after that update, we discovered another related issue that wasn't fully addressed:

When using Java's JFileChooser to select a file in a network folder set as the initial directory, the selected path would be returned as a UNC path.

In VCSSL, this can happen when using the choose(string directoryPath) function. We've now added a workaround to prevent this behavior.

This issue has already been reported to the OpenJDK community and accepted as JDK-8355342, but the fix will likely take some time on the Java side.

Fixed a Parsing Bug Involving Escaped Characters in String Literals Within Conditional Statements

This one is a bit technical, but we've fixed a parsing bug where certain escape sequences in string literals inside control statement parentheses (like if(...) or while(...)) weren't being interpreted correctly, resulting in strange errors -- even though the code was valid. Sorry about that!

-

That's it for the updates in this release!

We'll continue to post news and updates related to VCSSL here in this section, so stay tuned!