Changeset abb7491c in mainline
- Timestamp:
- 2011-08-25T21:42:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ff0c270
- Parents:
- 81e20c7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
r81e20c7 rabb7491c 655 655 int utf16_to_str(char *dest, size_t size, const uint16_t *src) 656 656 { 657 size_t idx =0, dest_off=0;657 size_t idx = 0, dest_off = 0; 658 658 wchar_t ch; 659 659 int rc = EOK; … … 664 664 while (src[idx]) { 665 665 if ((src[idx] & 0xfc00) == 0xd800) { 666 if (src[idx +1] && (src[idx+1] & 0xfc00) == 0xdc00) {666 if (src[idx + 1] && (src[idx + 1] & 0xfc00) == 0xdc00) { 667 667 ch = 0x10000; 668 668 ch += (src[idx] & 0x03FF) << 10; 669 ch += (src[idx +1] & 0x03FF);669 ch += (src[idx + 1] & 0x03FF); 670 670 idx += 2; 671 671 } … … 676 676 idx++; 677 677 } 678 rc = chr_encode(ch, dest, &dest_off, size -1);678 rc = chr_encode(ch, dest, &dest_off, size - 1); 679 679 if (rc != EOK) 680 680 break; … … 686 686 int str_to_utf16(uint16_t *dest, size_t size, const char *src) 687 687 { 688 int rc =EOK;689 size_t offset =0;690 size_t idx =0;688 int rc = EOK; 689 size_t offset = 0; 690 size_t idx = 0; 691 691 wchar_t c; 692 692 … … 695 695 while ((c = str_decode(src, &offset, STR_NO_LIMIT)) != 0) { 696 696 if (c > 0x10000) { 697 if (idx +2 >= size-1) {698 rc =EOVERFLOW;697 if (idx + 2 >= size - 1) { 698 rc = EOVERFLOW; 699 699 break; 700 700 } 701 701 c = (c - 0x10000); 702 702 dest[idx] = 0xD800 | (c >> 10); 703 dest[idx +1] = 0xDC00 | (c & 0x3FF);703 dest[idx + 1] = 0xDC00 | (c & 0x3FF); 704 704 idx++; 705 705 } else { … … 708 708 709 709 idx++; 710 if (idx >= size -1) {711 rc =EOVERFLOW;710 if (idx >= size - 1) { 711 rc = EOVERFLOW; 712 712 break; 713 713 }
Note:
See TracChangeset
for help on using the changeset viewer.