Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid character when using with Angular Universal #82

Open
rathahin opened this issue Jun 23, 2018 · 5 comments
Open

Invalid character when using with Angular Universal #82

rathahin opened this issue Jun 23, 2018 · 5 comments

Comments

@rathahin
Copy link

Version: v8.9.4
Platform: Darwin rathahin-mac.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

I am trying to build Angular Universal to Cordova. I got the error below:
screen shot 2018-06-23 at 7 12 03 pm

The variable is from the Angular Universal. I don't why they use that. Is there any work around to make VM able to recognize that variable.

Thanks

@jaimecbernardo
Copy link
Member

Hi @rathahin ,

Thank you for reporting. I've confirmed this is an issue for iOS. It works on Android, though. I've tested with the following code:

var Өad = "Ө";
console.log(
  "Versions: " + Өad + " - " +
  JSON.stringify(process.versions)
);

I suspect it's related to the fact that the native library is built with the --without-intl flag, meaning it won't have ICU in the build, and the ChakraCore JavaScript engine, which is used on iOS, might not support Unicode characters in the code without ICU.

My suggested workaround is to avoid using Unicode characters in JavaScript code on iOS. It might also be possible in Cordova to make a hook script to replace this unicode character for a set string during the prepare phase or add a script to do this to your build environment.

I hope this was helpful.
I've marked this issue with the bug label so we can track it.

@beevelop
Copy link

I can confirm the very same issue with greek symbols on iOS too. In my case, it appeared when trying to use a NLP lib: https://github.com/axa-group/nlp.js/blob/master/lib/nlp/stemmers/greek-stemmer.js#L391

Is there any way to either enable ICU support or at least, circumvent this issue in some form?

@jaimecbernardo
Copy link
Member

Hi @beevelop ,
nodejs-mobile is currently built without the ICU support for iOS.
A possible workaround would be replacing the characters by their unicode escape sequence.

@beevelop
Copy link

beevelop commented Oct 2, 2019

@jaimecbernardo thank you for the input. I decided to go with another approach: Building a version of nodejs-mobile with support for ICU. I tested it for Android and it seems to work properly. For anyone trying to achieve the same. You need to replace a few lines:

Code snippet / diff

diff --git a/android-configure b/android-configure
index fc9dcf1223..b43bc6a3ad 100755
--- a/android-configure
+++ b/android-configure
@@ -94,7 +94,9 @@ if [ -f "configure" ]; then
         --dest-os=android \
         --without-snapshot \
         --openssl-no-asm \
-        --with-intl=none \
+        --without-inspector \
+        --with-intl=full-icu \
+        --download=all \
         --engine=V8 \
         --cross-compiling \
         --shared
diff --git a/tools/ios_framework_prepare.sh b/tools/ios_framework_prepare.sh
index 8bac4ba5bf..c9e28b0fc1 100755
--- a/tools/ios_framework_prepare.sh
+++ b/tools/ios_framework_prepare.sh
@@ -17,7 +17,7 @@ make clean

 TARGET_LIBRARY_PATH='tools/ios-framework/bin/arm64'

-./configure --dest-os=ios --dest-cpu=arm64 --without-chakra-jit --enable-static --with-intl=none --openssl-no-asm
+./configure --dest-os=ios --dest-cpu=arm64 --without-chakra-jit --enable-static --with-intl=full-icu --download=all --without-inspector --openssl-no-asm
 make -j$(getconf _NPROCESSORS_ONLN)

 mkdir -p $TARGET_LIBRARY_PATH
@@ -36,7 +36,7 @@ make clean

 TARGET_LIBRARY_PATH='tools/ios-framework/bin/x64'

-./configure --dest-os=ios --dest-cpu=x64 --without-chakra-jit --enable-static --with-intl=none --openssl-no-asm
+./configure --dest-os=ios --dest-cpu=x64 --without-chakra-jit --enable-static --with-intl=full-icu --download=all --without-inspector --openssl-no-asm
 make -j$(getconf _NPROCESSORS_ONLN)

 mkdir -p $TARGET_LIBRARY_PATH

Depending on your machine, it might take quite some time to run the build. I spun up a VM with 32 CPUs to get this done in a timely manner.

@jaimecbernardo
Copy link
Member

Hi @beevelop , Thank you for sharing this development!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants