forked from mmp/pbrt-v4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize unicode strings for user-supplied names (objects, materials, media, etc.) Note that there is no need to normalize strings for things like the name of the selected sampler, light source types, or the parameters provided to pbrt objects, as all of the valid ones are plain old ASCII text. We also intentionally do not normalize pathnames, as doing so can cause all sorts of trouble.
- Loading branch information
Showing
8 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// pbrt is Copyright(c) 1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys. | ||
// The pbrt source code is licensed under the Apache License, Version 2.0. | ||
// SPDX: Apache-2.0 | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <pbrt/pbrt.h> | ||
#include <pbrt/util/string.h> | ||
|
||
#include <string> | ||
|
||
using namespace pbrt; | ||
|
||
TEST(Unicode, BasicNormalization) { | ||
// "Amélie" two ways, via https://en.wikipedia.org/wiki/Unicode_equivalence | ||
std::u16string nfc16(u"\u0041\u006d\u00e9\u006c\u0069\u0065"); | ||
std::u16string nfd16(u"\u0041\u006d\u0065\u0301\u006c\u0069\u0065"); | ||
EXPECT_NE(nfc16, nfd16); | ||
|
||
std::string nfc8 = UTF8FromUTF16(nfc16); | ||
std::string nfd8 = UTF8FromUTF16(nfd16); | ||
EXPECT_NE(nfc8, nfd8); | ||
|
||
EXPECT_EQ(nfc8, NormalizeUTF8(nfc8)); // nfc is already normalized | ||
EXPECT_EQ(nfc8, NormalizeUTF8(nfd8)); // normalizing nfd should make it equal nfc | ||
} |