node-iconv | node.js iconv bindings - text recoding for fun and profit | Runtime Evironment library
kandi X-RAY | node-iconv Summary
kandi X-RAY | node-iconv Summary
node.js iconv bindings - text recoding for fun and profit!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Convert a binary input into a buffer .
- Initialize a new Iconv .
- Fix an encoding to valid encoding .
- Create an error handler
node-iconv Key Features
node-iconv Examples and Code Snippets
import * as iconv from 'iconv-jschardet';
import iconv from 'iconv-jschardet';
const BIG5_HEX = 'a6b8b160a5ceb0eaa672bcd0b7c7a672c5e9aaed';
// utf8 buffer
iconv.BufferFrom(Buffer.from(BIG5_HEX, 'hex'), 'utf8')
iconv.BufferFrom(BIG5_HEX, 'utf8', 'h
import * as iconv from 'iconv';
import { deEncapsulateSync } from 'rtf-stream-parser';
const decode = (buf, enc) => {
const converter = new iconv.Iconv(enc, 'UTF-8//TRANSLIT//IGNORE');
return converter.convert(buf).toString('utf8');
};
c
operation iconv@2.1.4 iconv-lite@0.4.7
----------------------------------------------------------
encode('win1251') ~96 Mb/s ~320 Mb/s
decode('win1251') ~95 Mb/s ~246 Mb/s
#!/bin/bash
to_ascii() {
case $(uname) in
Darwin)
iconv -f UTF-8 -t UTF-8-MAC "$@" |
iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE
;;
Linux)
iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE "$@"
;;
echo -n '{"message":"Hello world"}' | iconv -t utf-8 | md5sum | cut -d' ' -f1 | xxd -r -p | base64
jANzQ+rgAHyf1MWQFSwvYw==
% cc extract_instruments.c -o extract_instruments
% cat AFRICA_55.MID| ./extract_instruments| iconv -f SHIFT-JIS -t UTF8
【 AFRICA / TOTO 】 for SC-55 by 染之介
...
#include
/*
Acknowledgement:
ReadVar
bash$ python
>>> print([hex(ord(x)) for x in '\350\343\240\317\344\307\345\331\307'])
['0xe8', '0xe3', '0xa0', '0xcf', '0xe4', '0xc7', '0xe5', '0xd9', '0xc7']
>>> print(b'\350\343\240\317\344\307\
$ # first get octal representation of range unicode code points
$ # iconv is to convert to utf-8 in case your locale is not utf-8
$ printf "\u3131\uD79D" | iconv -t utf-8 | od -An -to1
343 204 261 355 236 235
$ # format it as a sed range
const urlencode = require("urlencode");
const iconv = require("iconv-lite");
const qs = require("querystring");
server.use(
bodyParser.raw({ type: "application/x-www-form-urlencoded" }),
(req, res, next) => {
if (req.method ===
#!/usr/bin/env sh
cat <
o These are
o UTF-8 bullets in source
o But it can gracefully degrade with recode
#!/usr/bin/env sh
cat <
o These are
o UTF-
Community Discussions
Trending Discussions on node-iconv
QUESTION
Before I give some background, I'd like to clarify that I'm not looking for how to simply spawn a new script under the Electron runtime as a renderer process, I'm trying to use a plain Node runtime.
So I'm aware Electron has some different flavor of a JS runtime under its hood similar to NW.js and I'm trying to get consistent performant results for my report.
Unfortunately, this seems to be much more difficult than I had imagined. I'm specifically testing the speed of the mailparser
module although that's not necessarily important here.
I first ran it on the Electron app we're working with, which uses Electron Forge. I called the test script through IPC as that's what we intend to use, so it was called within the callback for
ipcMain.handle
. Here, the performance was really bad and it was taking 30-50 seconds for our test to complete.I then ran a test script that just opens a blank HTML file in the same Electron Forge app, and runs the test script in the background. This was much better at 8-12 seconds.
Next, I set up a new directory with a test set, a plain Electron installation, and a mailparser
installation. I did not electron-rebuild
here, but mailparser
does rely on node-iconv
and so has native bindings.
I ran a test script with Electron just calling the same line of code. This did not use Electron Forge. The performance here was slightly better at 5-9 seconds.
I then ran another test script, this time just with plain old node, and the performance here was excellent at 1-3s.
So I have two questions here:
Why is the performance varying so much in the Electron tests? Although I used IPCMain, I used the new
.handle
which should be asynchronous and run in the context of Electron's node runtime, so it should have the same performance as running outside the callback. Moreover, the Electron Forge and plain Electron tests also differ by a couple of seconds which made no sense to me as I assumed Electron Forge would just wrap the Electron binary under the hood.Seeking optimal and consistent results, I'm wondering how I can spin up a child process with the node runtime inside Electron. Doing this normally just starts a new renderer process which is running Electron's (slower) JS runtime. I'd like to avoid leaving Electron Forge but the only solution I can think of is to bundle precompiled binaries with the process running under the Node runtime built for each platform.
ANSWER
Answered 2020-Nov-27 at 18:43For question 1 it’s hard to know what the problem is without being able to replicate it in code. You might try posting an issue on the Github site for the Electron team re this. They are more likely to know the answer, but they ask for code as well.
Having said that, it isn’t that hard to spin up a child process that is just running node and frees you from Electron/Electron Forge overhead. The easiest is to use node’s fork command, but to tell it to use the main node executable rather than electron.exe. You can just hand it a script to run, so you don’t need to worry about precompiled binaries.
The code below (and here) running on the main process will run a script called server.js in the same folder:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-iconv
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page