OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // by TryCatch above. | 58 // by TryCatch above. |
59 if (!value->IsUndefined() && !value->IsNull() && value->IsString()) { | 59 if (!value->IsUndefined() && !value->IsNull() && value->IsString()) { |
60 v8::String::Utf8Value utf8_value(value); | 60 v8::String::Utf8Value utf8_value(value); |
61 if (*utf8_value == NULL) return false; | 61 if (*utf8_value == NULL) return false; |
62 result->setTo(icu::UnicodeString::fromUTF8(*utf8_value)); | 62 result->setTo(icu::UnicodeString::fromUTF8(*utf8_value)); |
63 return true; | 63 return true; |
64 } | 64 } |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
| 68 // static |
| 69 void I18NUtils::AsciiToUChar(const char* source, |
| 70 int32_t source_length, |
| 71 UChar* target, |
| 72 int32_t target_length) { |
| 73 int32_t length = |
| 74 source_length < target_length ? source_length : target_length; |
| 75 |
| 76 if (length <= 0) { |
| 77 return; |
| 78 } |
| 79 |
| 80 for (int32_t i = 0; i < length - 1; ++i) { |
| 81 target[i] = static_cast<UChar>(source[i]); |
| 82 } |
| 83 |
| 84 target[length - 1] = 0x0u; |
| 85 } |
| 86 |
68 } } // namespace v8::internal | 87 } } // namespace v8::internal |
OLD | NEW |