Skip to content

fix: wchar handling#107

Merged
ahmad-kemsan merged 4 commits intomasterfrom
huzaif/wchar_handling
Apr 10, 2026
Merged

fix: wchar handling#107
ahmad-kemsan merged 4 commits intomasterfrom
huzaif/wchar_handling

Conversation

@mir-huzaif
Copy link
Copy Markdown
Contributor

No description provided.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
60.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes wide character (wchar) handling for cross-platform compatibility between Windows (UTF-16) and Unix-based systems (UTF-8). The fix addresses an issue where character buffer sizes were incorrectly calculated on Windows, which uses 2-byte UTF-16 encoding (wchar_t).

Key Changes:

  • Added platform-specific character count calculation in C++ to properly handle UTF-16 on Windows
  • Introduced a TypeScript helper function to allocate appropriately sized buffers based on platform encoding
  • Applied these changes consistently across 30+ API functions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 26 comments.

File Description
src/native/main.cpp Added getCharCount() function to convert byte lengths to character counts (dividing by 2 on Windows for UTF-16), and updated all buffer length calculations to use this function with proper error handling
src/lexactivator-native.ts Added getCArray() function to allocate buffers with correct byte sizes (doubled on Windows for UTF-16 encoding)
src/lexactivator.ts Replaced all direct Uint8Array instantiations with calls to getCArray() to ensure proper buffer allocation across platforms

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
Comment thread src/native/main.cpp Outdated
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
64.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@ahmad-kemsan ahmad-kemsan merged commit de0a2b8 into master Apr 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants