From 8ef500bc0b259cf6a73772148153b759e954297e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 22 Apr 2022 23:52:29 -0700 Subject: C++11 introduced actual unicode string literals. I'm moving things to take advantage of that. It's pretty cool! --- src/tests/archivetags.cpp | 8 +++++++- src/tests/text.cpp | 9 +++++++++ src/unstable/text.cpp | 10 ++++++++++ src/unstable/text.h | 3 ++- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/tests/text.cpp (limited to 'src') diff --git a/src/tests/archivetags.cpp b/src/tests/archivetags.cpp index 5c8e0fa..b9b3603 100644 --- a/src/tests/archivetags.cpp +++ b/src/tests/archivetags.cpp @@ -1,4 +1,4 @@ - +/* class SubThing { public: @@ -70,4 +70,10 @@ Bu::Archive &operator>>( Bu::Archive &ar, Something &st ) ar >> ar.tag("thing") >> st.xThing; return ar; } +*/ + +int main( int argc, char *argv[] ) +{ + return 0; +} diff --git a/src/tests/text.cpp b/src/tests/text.cpp new file mode 100644 index 0000000..0b99e3b --- /dev/null +++ b/src/tests/text.cpp @@ -0,0 +1,9 @@ +#include "bu/text.h" + +int main( int argc, char *argv[] ) +{ + Bu::Text txt(UR"sql(Hello there!""''"")sql"); + + return 0; +} + diff --git a/src/unstable/text.cpp b/src/unstable/text.cpp index be4c10f..d8cf15c 100644 --- a/src/unstable/text.cpp +++ b/src/unstable/text.cpp @@ -19,6 +19,16 @@ Bu::Text::Text() : { } +Bu::Text::Text( const CodePoint *rSrc ) : + pData( NULL ), + bIsBmpOnly( true ), + iSize( 0 ) +{ + for(; rSrc[iSize]; iSize++ ) {} + pData = new CodePoint[iSize+1]; + memcpy( pData, rSrc, iSize+1 ); +} + Bu::Text::Text( const Text &rSrc ) : pData( NULL ), bIsBmpOnly( rSrc.bIsBmpOnly ), diff --git a/src/unstable/text.h b/src/unstable/text.h index c57dcfb..43e9e2c 100644 --- a/src/unstable/text.h +++ b/src/unstable/text.h @@ -35,10 +35,11 @@ namespace Bu public: class iterator; class const_iterator; - typedef uint32_t CodePoint; + typedef char32_t CodePoint; public: Text(); + Text( const CodePoint *rSrc ); Text( const Text &rSrc ); Text( const TextBuilder &rSrc ); virtual ~Text(); -- cgit v1.2.3