LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   general question about javascript (https://www.linuxquestions.org/questions/linux-newbie-8/general-question-about-javascript-4175450540/)

tautvilas 02-17-2013 09:59 AM

general question about javascript
 
here is a competition called js1k and they state in there page this rule :

Note that we're not counting in characters. JavaScript uses 16bit unicode values internally. The server will enforce this restriction and reject your submission if you try anyways.

Everybody submits ~1024 characters source files. Javascript uses 16 bit unicode to encode every character in the source code, which means that the submit file of ~1024 characters is ~2048 bytes size and this shouldn't be allowed to submit. What is that I don't get?

Thanks

shivaa 02-17-2013 10:41 AM

Perhaps it points to size of the file to be submitted. As far as I understood, a file which is to be submitted, should have less than or equal to 1024 characters. (Note: A tilde "~" symbol means approximately). So in your case, server where you're submitting your source code file, will not accept files having more than 1024 characters.
Therefore, before submission, check no. of characters in your source code, as:
Code:

~$ wc -c source_code.txt

AnanthaP 02-19-2013 02:06 AM

A character in ASCII usually needs 8 bits. As per the OP, Javascript needs 16 bits (or 2 bytes) internally for a character. So 1024 bytes gives only 512 characters. Submissions > 512 characters in size will not be accepted since they would require > 1024 bytes.

OK


All times are GMT -5. The time now is 02:17 PM.