summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
authorNick Peskett <rockbox@peskett.co.uk>2011-12-20 08:15:36 +0000
committerNick Peskett <rockbox@peskett.co.uk>2011-12-20 08:15:36 +0000
commit1b781df59c1b61009f36b64876372a00411b8be0 (patch)
treedf4b5cceeadf560f084d43d683ebaab689fa805e /apps/misc.c
parentc24a36dd9d54f4f77fb40b63fba1c76bac764aa6 (diff)
Convert hard-coded unicode byte order mark values to constants.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31374 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 407a26c90f..b1def596ab 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1011,13 +1011,11 @@ void format_time(char* buf, int buf_size, long t)
* If the file is opened for writing and O_TRUNC is set, write a BOM to
* the opened file and leave the file pointer set after the BOM.
*/
-#define BOM "\xef\xbb\xbf"
-#define BOM_SIZE 3
int open_utf8(const char* pathname, int flags)
{
int fd;
- unsigned char bom[BOM_SIZE];
+ unsigned char bom[BOM_UTF_8_SIZE];
fd = open(pathname, flags, 0666);
if(fd < 0)
@@ -1025,13 +1023,13 @@ int open_utf8(const char* pathname, int flags)
if(flags & (O_TRUNC | O_WRONLY))
{
- write(fd, BOM, BOM_SIZE);
+ write(fd, BOM_UTF_8, BOM_UTF_8_SIZE);
}
else
{
- read(fd, bom, BOM_SIZE);
+ read(fd, bom, BOM_UTF_8_SIZE);
/* check for BOM */
- if(memcmp(bom, BOM, BOM_SIZE))
+ if(memcmp(bom, BOM_UTF_8, BOM_UTF_8_SIZE))
lseek(fd, 0, SEEK_SET);
}
return fd;