Skip to content

Commit

Permalink
feat(android): remove implicit conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
medns authored and zoomchan-cxj committed Aug 10, 2022
1 parent b5eb7bb commit c7b1436
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
9 changes: 5 additions & 4 deletions core/include/core/base/string_view_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ class StringViewUtils {
case unicode_string_view::Encoding::Latin1: {
u8string u8;
for (const auto& ch : str_view.latin1_value()){
if (static_cast<uint8_t>(ch) < 0x80) {
u8 += ch;
auto c = static_cast<uint8_t>(ch);
if (c < 0x80) {
u8 += c;
} else {
u8 += (0xc0 | ch >> 6);
u8 += (0x80 | (ch & 0x3f));
u8 += (0xc0 | c >> 6);
u8 += (0x80 | (c & 0x3f));
}
}
return unicode_string_view(std::move(u8));
Expand Down
27 changes: 24 additions & 3 deletions core/third_party/base/include/base/logging.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
// Copyright 2020 Tencent
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once
#include <cassert>
#include <codecvt>
Expand All @@ -25,8 +46,8 @@ inline std::ostream& operator<<(std::ostream& stream, const unicode_string_view&
if (static_cast<uint8_t>(ch) < 0x80) {
u8 += ch;
} else {
u8 += (0xc0 | ch >> 6);
u8 += (0x80 | (ch & 0x3f));
u8 += static_cast<char>(0xc0 | ch >> 6);
u8 += static_cast<char>(0x80 | (ch & 0x3f));
}
}
stream << u8;
Expand Down

0 comments on commit c7b1436

Please sign in to comment.