I tried that and still get an error that says isValid is not a function?
C:\nodejs>node buftest.js
buffer
C:\nodejs\buftest.js:9
if (isValid(buf1)){
^
TypeError: isValid is not a function
at Object.<anonymous> (C:\nodejs\buftest.js:9:5)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
'use strict';
var isValid = require('utf-8-validate').isValidUTF8;
const buf1 = new Buffer('buffer');
console.log(buf1.toString());
if (isValid(buf1)){
console.log('true')
}
else {
console.log('false')
};
On Thursday, April 21, 2016 at 9:46:24 PM UTC-7, Matt Sergeant wrote:
> In the above example, you just use: if (isValid(buf)) { ... }
>
>
> On Thu, Apr 21, 2016 at 4:20 PM, Bryon Trott <[email protected]
> <javascript:>> wrote:
>
>> Hello,
>> I am new to node.js I am trying to use the module UTF-8-Validate to
>> check a simple test buffer.
>> https://www.npmjs.com/package/utf-8-validate
>>
>> However I am not sure how to call the function.
>>
>>
>> 'use strict';
>>
>> var isValid = require('utf-8-validate').isValidUTF8;
>>
>> The module exposes 1 function:
>> *isValidUTF8* <https://www.npmjs.com/package/utf-8-validate#isvalidutf8>
>>
>> Validate if the passed in buffer contains valid UTF-8 chars.
>>
>> bu.isValidUTF8(buffer);
>>
>>
>>
>> If anybody know how to do this or can point me to some sample code it
>> would be very helpful.
>>
>> Thanks
>>
>> --
>> Job board: http://jobs.nodejs.org/
>> New group rules:
>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>> Old group rules:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/nodejs/01a2b4b9-961a-4f2d-b6cb-3021ef8dec89%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/nodejs/01a2b4b9-961a-4f2d-b6cb-3021ef8dec89%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/e67b3fe3-26d6-434c-8eb1-2b98b5098ad8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.