mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
901 B
34 lines
901 B
10 years ago
|
/*
|
||
|
* Hex escapes in C code can be confusing; this is non-portable:
|
||
|
*
|
||
|
* const char *str = "\xffab";
|
||
|
*
|
||
|
* GCC will warn:
|
||
|
*
|
||
|
* warning: hex escape sequence out of range [enabled by default]
|
||
|
*
|
||
|
* To avoid this, you can e.g. use the following form:
|
||
|
*
|
||
|
* const char *str = "\xff" "ab";
|
||
|
*
|
||
|
* If the C hex escape is terminated by a character that cannot be a
|
||
|
* valid hex digit, there is no need for this (but breaking up the
|
||
|
* string is still good practice), e.g.:
|
||
|
*
|
||
|
* const char *str = "\xffquux";
|
||
|
*
|
||
|
* Another hex escape always terminates a previous hex escape. For
|
||
|
* instance, to write a user internal property constant with two
|
||
|
* leading 0xFF bytes:
|
||
|
*
|
||
|
* const char *str = "\xff\xff" "quux";
|
||
|
*/
|
||
|
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
const char *str = "\xffabcdef"; /* Generates a warning on GCC */
|
||
|
printf("%s\n", str);
|
||
|
return 0;
|
||
|
}
|