UTF-8 to UTF-16 transformation
PATCH 1/1 UTF-8 to UTF-16 transformation
Splitted from my newtree patch
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 8 lines · Vladimir 'phcoder' Serbinenko
Splitted from my newtree patch
--
Regards
Vladimir 'phcoder' SerbinenkoPersonal git repository: http://repo.or.cz/w/grub2/phcoder.git
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
2009-08-24 Vladimir Serbinenko <[email protected]>
UTF-8 to UTF-16 transformation.
* conf/common.rmk (pkglib_MODULES): Add utf.mod (utf_mod_SOURCES): New variable.
(utf_mod_CFLAGS): Likewise.
(utf_mod_LDFLAGS): Likewise.
* include/grub/utf.h: New file.
* lib/utf.c: New file. (Based on grub_utf8_to_ucs4 from kern/misc.c)
conf/common.rmk +5 -0
@@ -617,3 +617,8 @@ pkglib_MODULES += setjmp.mod setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS) + +pkglib_MODULES += utf.mod +utf_mod_SOURCES = lib/utf.c +utf_mod_CFLAGS = $(COMMON_CFLAGS) +utf_mod_LDFLAGS = $(COMMON_LDFLAGS)
include/grub/utf.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2009 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef GRUB_UTF_HEADER +#define GRUB_UTF_HEADER 1 + +#include <grub/types.h> + +grub_ssize_t +grub_utf8_to_utf16 (grub_uint16_t *dest,grub_size_t destsize, +const grub_uint8_t *src,grub_size_t srcsize, +const grub_uint8_t **srcend); + +#endif
lib/utf.c new file +116 -0
116 lines not on this page · raw message
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
2009-08-24 Vladimir Serbinenko <[email protected]>
UTF-8 to UTF-16 transformation.
* conf/common.rmk (
pkglib_MODULES): Add utf.mod (utf_mod_SOURCES): New variable.
(utf_mod_CFLAGS): Likewise.
(utf_mod_LDFLAGS): Likewise.
*include/grub/utf.h: New file.
*lib/utf.c: New file. (Based ongrub_utf8_to_ucs4fromkern/misc.c)
Sounds like we could end up needing more of this (to other charsets), so why not give this module a generic name to hint as to where it can be added?
The conversion functions in kern/misc.c could eventually move there as well, once UTF-8 support becomes optional in the kernel.
GNU libc has "iconv" command and "iconv_*" facilities for charset conversion, how about iconv.mod for consistency?
lib/utf.c line 66
Quoted 3 lines
lib/utf.c new file +3
-0+if ((c &0x80 ) ==0x00 ) + code = c; +else if ((c &0xe0 ) ==0xc0 )
These should be macroified.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 2 lines · Robert Millan
GNU libc has "iconv" command and "iconv_*" facilities for charset conversion, how about iconv.mod for consistency?
My 2 cents is: that might be confusing. At least, if I saw iconv.mod, I would assume it was really GNU libc's iconv library.
char_conv.mod?
charset_conv.mod?
charset.mod?
Quoted 13 lines · Robert Millan
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
2009-08-24 Vladimir Serbinenko <[email protected]>
UTF-8 to UTF-16 transformation.
* conf/common.rmk (
pkglib_MODULES): Add utf.mod (utf_mod_SOURCES): New variable.
(utf_mod_CFLAGS): Likewise.
(utf_mod_LDFLAGS): Likewise.
*include/grub/utf.h: New file.
*lib/utf.c: New file. (Based ongrub_utf8_to_ucs4fromkern/misc.c)
Quoted 3 lines
Sounds like we could end up needing more of this (to other charsets), so why not give this module a generic name to hint as to where it can be added?
I'm ok with renaming but whether a conversion goes to charset.mod is perhaps to be decided on case-by-case basis-
Quoted 2 lines
The conversion functions in
kern/misc.ccould eventually move there as well, once UTF-8 support becomes optional in the kernel.
utf16_to_utf8 can be moved now out of the kernel but it's used by some fs modules (e.g. fat). Perhaps utf16_to_utf8 should be a separate module? This would decrease the size of biggest cores with the price of its increase in smaller cores.
Quoted 10 lines
GNU libc has "iconv" command and "iconv_*" facilities for charset conversion, how about iconv.mod for consistency?
Quoted 3 lines
+ if ((c &
0x80) ==0x00)
+ code = c;
+ else if ((c &0xe0) ==0xc0)These should be macroified.
Actually this are accelerated bitchecks (bit numbers follow specific and easy pattern) and for real readability would have to be written in binary but AFAIK binary notation isn't supported in C code and would result in overly long strings
Quoted 13 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Installing Solaris without a CDROM
Hi,
You asked about it -- yes, there is. You can install it via a USB storage
device (if your BIOS can boot from it).
Take a look at this:
http://opensolaris.org/jive/thread.jspa?threadID=107723&tstart=45
--S
Quoted 61 lines · Vladimir 'phcoder' Serbinenko
Quoted 13 lines · Robert Millan
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
2009-08-24 Vladimir Serbinenko <[email protected]>
UTF-8 to UTF-16 transformation.
* conf/common.rmk (
pkglib_MODULES): Add utf.mod (utf_mod_SOURCES): New variable.
(utf_mod_CFLAGS): Likewise.
(utf_mod_LDFLAGS): Likewise.
*include/grub/utf.h: New file.
*lib/utf.c: New file. (Based ongrub_utf8_to_ucs4fromkern/misc.c)Quoted 3 lines
Sounds like we could end up needing more of this (to other charsets), so why not give this module a generic name to hint as to where it can be added?
I'm ok with renaming but whether a conversion goes to charset.mod is perhaps to be decided on case-by-case basis-
Quoted 2 lines
The conversion functions in
kern/misc.ccould eventually move there as well, once UTF-8 support becomes optional in the kernel.
utf16_to_utf8can be moved now out of the kernel but it's used by some fs modules (e.g. fat). Perhapsutf16_to_utf8should be a separate module? This would decrease the size of biggest cores with the price of its increase in smaller cores.Quoted 10 lines
GNU libc has "iconv" command and "iconv_*" facilities for charset conversion, how about iconv.mod for consistency?
Quoted 3 lines
+ if ((c &
0x80) ==0x00)
+ code = c;
+ else if ((c &0xe0) ==0xc0)These should be macroified.
Actually this are accelerated bitchecks (bit numbers follow specific and easy pattern) and for real readability would have to be written in binary but AFAIK binary notation isn't supported in C code and would result in overly long strings
Quoted 8 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel--
Regards
Vladimir 'phcoder' SerbinenkoPersonal git repository: http://repo.or.cz/w/grub2/phcoder.git
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +11 -0
@@ -158,6 +158,17 @@ 2009-08-24 Vladimir Serbinenko <[email protected]> + UTF-8 to UTF-16 transformation. + + * conf/common.rmk (pkglib_MODULES): Add utf.mod + (utf_mod_SOURCES): New variable. + (utf_mod_CFLAGS): Likewise. + (utf_mod_LDFLAGS): Likewise. + * include/grub/utf.h: New file. + * lib/utf.c: New file. (Based on grub_utf8_to_ucs4 from kern/misc.c) + +2009-08-24 Vladimir Serbinenko <[email protected]> + * script/sh/function.c (grub_script_function_find): Cut error message not to flood terminal. * script/sh/lexer.c (grub_script_yylex): Remove command line length
conf/common.rmk +5 -0
@@ -633,3 +633,8 @@ pkglib_MODULES += setjmp.mod setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS) + +pkglib_MODULES += charset.mod +charset_mod_SOURCES = lib/charset.c +charset_mod_CFLAGS = $(COMMON_CFLAGS) +charset_mod_LDFLAGS = $(COMMON_LDFLAGS)
include/grub/charset.h new file +50 -0
50 lines not on this page · raw message
lib/charset.c new file +116 -0
116 lines not on this page · raw message
Quoted 17 lines · Vladimir 'phcoder' Serbinenko
Quoted 13 lines · Robert Millan
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
2009-08-24 Vladimir Serbinenko <[email protected]>
UTF-8 to UTF-16 transformation.
* conf/common.rmk (
pkglib_MODULES): Add utf.mod (utf_mod_SOURCES): New variable.
(utf_mod_CFLAGS): Likewise.
(utf_mod_LDFLAGS): Likewise.
*include/grub/utf.h: New file.
*lib/utf.c: New file. (Based ongrub_utf8_to_ucs4fromkern/misc.c)Quoted 3 lines
Sounds like we could end up needing more of this (to other charsets), so why not give this module a generic name to hint as to where it can be added?
Quoted 8 lines
I'm ok with renaming but whether a conversion goes to charset.mod is perhaps to be decided on case-by-case basis-
Quoted 2 lines
The conversion functions in
kern/misc.ccould eventually move there as well, once UTF-8 support becomes optional in the kernel.
utf16_to_utf8can be moved now out of the kernel but it's used by some fs modules (e.g. fat). Perhapsutf16_to_utf8should be a separate module? This would decrease the size of biggest cores with the price of its increase in smaller cores.
Uhm perhaps we should use inline functions then. What do you think?
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
+ if ((c &
0x80) ==0x00)
+ code = c;
+ else if ((c &0xe0) ==0xc0)These should be macroified.
Actually this are accelerated bitchecks (bit numbers follow specific and easy pattern) and for real readability would have to be written in binary but AFAIK binary notation isn't supported in C code and would result in overly long strings
Ah, right. Then it's not a problem. Maybe with (1 << 7) instead of 0x80, if you prefer.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 10 lines
Quoted 8 lines
I'm ok with renaming but whether a conversion goes to charset.mod is perhaps to be decided on case-by-case basis-
Quoted 2 lines
The conversion functions in
kern/misc.ccould eventually move there as well, once UTF-8 support becomes optional in the kernel.
utf16_to_utf8can be moved now out of the kernel but it's used by some fs modules (e.g. fat). Perhapsutf16_to_utf8should be a separate module? This would decrease the size of biggest cores with the price of its increase in smaller cores.Uhm perhaps we should use inline functions then. What do you think?
For me it's ok. During my tests with misc.c I checked this one too and on 3 filesystems using utf16_to_utf I had following results:
core pc+fat+biosdisk: 7 bytes decrease
core pc+hfsplus+biosdisk: 2 bytes increase.
core pc+ntfs+biosdisk: 33 bytes decrease
I haven't checked the size with filesystems not using utf16_to_utf8. Unfortunately USB uses this function too. I'll look if it's essential and inlining effects on core.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
+ if ((c &
0x80) ==0x00)
+ code = c;
+ else if ((c &0xe0) ==0xc0)These should be macroified.
Quoted 8 lines
Quoted 4 lines
Actually this are accelerated bitchecks (bit numbers follow specific and easy pattern) and for real readability would have to be written in binary but AFAIK binary notation isn't supported in C code and would result in overly long strings
Ah, right. Then it's not a problem. Maybe with (1 << 7) instead of
0x80, if you prefer.
In second version I macroified these values (as
GRUB_UINT8_*_(LEADING|TRAILING)_BIT[S] )
Quoted 13 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git