From 247d5f7e8673252e6c37139a4e6dc21c45c57c27 Mon Sep 17 00:00:00 2001 From: Rich E <rich.eakin@gmail.com> Date: Fri, 18 Jul 2014 14:12:03 -0400 Subject: [PATCH] begin fixing breaks from unicode updates. still many more to go. --- src/cinder/ImageIo.cpp | 14 +++++++++++--- src/cinder/Surface.cpp | 3 ++- src/cinder/Url.cpp | 5 +++-- src/cinder/app/AppImplWinRT.cpp | 5 +++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/cinder/ImageIo.cpp b/src/cinder/ImageIo.cpp index 8ec91e1a8d..260310327e 100644 --- a/src/cinder/ImageIo.cpp +++ b/src/cinder/ImageIo.cpp @@ -40,6 +40,7 @@ #include <ppltasks.h> #include "cinder/WinRTUtils.h" #include "cinder/Utilities.h" + #include "cinder/msw/CinderMsw.h" using namespace Windows::Storage; using namespace Concurrency; #endif @@ -390,7 +391,7 @@ void loadImageAsync(const fs::path path, std::function<void (ImageSourceRef)> ca auto copyTask = winrt::copyFileToTempDirAsync(path); copyTask.then([options, extension, callback](StorageFile^ file) { - fs::path temp = fs::path(toUtf8(file->Path->Data())); + fs::path temp = fs::path( msw::toUtf8String( file->Path->Data() ) ); // Image was loaded. This callback is on the main UI thread callback(loadImage(temp, options, extension)); winrt::deleteFileAsync(temp); @@ -413,8 +414,11 @@ ImageSourceRef loadImage( DataSourceRef dataSource, ImageSource::Options options #endif if( extension.empty() ) +#if ! defined( CINDER_WINRT ) extension = dataSource->getFilePathHint().extension().string(); - +#else + extension = dataSource->getFilePathHint().extension(); +#endif return ImageIoRegistrar::createSource( dataSource, options, extension ); } @@ -430,8 +434,12 @@ void writeImage( DataTargetRef dataTarget, const ImageSourceRef &imageSource, Im #endif if( extension.empty() ) +#if ! defined( CINDER_WINRT ) extension = getPathExtension( dataTarget->getFilePathHint().extension().string() ); - +#else + extension = getPathExtension( dataTarget->getFilePathHint().extension() ); +#endif + ImageTargetRef imageTarget = ImageIoRegistrar::createTarget( dataTarget, imageSource, options, extension ); if( imageTarget ) { writeImage( imageTarget, imageSource ); diff --git a/src/cinder/Surface.cpp b/src/cinder/Surface.cpp index 2ed4f569f3..7c3956f9a2 100644 --- a/src/cinder/Surface.cpp +++ b/src/cinder/Surface.cpp @@ -28,6 +28,7 @@ #include <ppltasks.h> #include "cinder/WinRTUtils.h" #include "cinder/Utilities.h" +#include "cinder/msw/CinderMsw.h" using namespace Windows::Storage; using namespace Concurrency; #undef max @@ -291,7 +292,7 @@ void SurfaceT<T>::loadImageAsync(const fs::path path, SurfaceT &surface, const S auto copyTask = winrt::copyFileToTempDirAsync(path); copyTask.then([path, &surface,constraints,alpha](StorageFile^ file) { - fs::path temp = fs::path(toUtf8(file->Path->Data())); + fs::path temp = fs::path( msw::toUtf8String( file->Path->Data() ) ); surface = SurfaceT(loadImage(fs::path(temp)),constraints, alpha); winrt::deleteFileAsync(temp); }); diff --git a/src/cinder/Url.cpp b/src/cinder/Url.cpp index 89dffe7401..1b17a7218f 100644 --- a/src/cinder/Url.cpp +++ b/src/cinder/Url.cpp @@ -36,6 +36,7 @@ typedef cinder::IStreamUrlImplCocoa IStreamUrlPlatformImpl; #elif defined( CINDER_WINRT ) #include "cinder/WinRTUtils.h" + #include "cinder/msw/CinderMsw.h" #include <wrl/client.h> #include <agile.h> using namespace Windows::Storage; @@ -70,9 +71,9 @@ std::string Url::encode( const std::string &unescaped ) UrlEscape( (wchar_t*)wideUnescaped.c_str(), (wchar_t*)buffer, &bufferSize, 0 ); return toUtf8( buffer ); #elif defined( CINDER_WINRT ) - std::wstring urlStr = toUtf16( unescaped ); + std::wstring urlStr = msw::toWideString( unescaped ); auto uri = ref new Windows::Foundation::Uri(ref new Platform::String(urlStr.c_str())); - return toUtf8( std::wstring( uri->AbsoluteCanonicalUri->Data())); + return msw::toUtf8String( std::wstring( uri->AbsoluteCanonicalUri->Data())); #endif } diff --git a/src/cinder/app/AppImplWinRT.cpp b/src/cinder/app/AppImplWinRT.cpp index 2d071e7aec..f0f5be5611 100644 --- a/src/cinder/app/AppImplWinRT.cpp +++ b/src/cinder/app/AppImplWinRT.cpp @@ -34,6 +34,7 @@ #include "cinder/Display.h" #include "cinder/WinRTUtils.h" #include "cinder/Utilities.h" +#include "cinder/msw/CinderMsw.h" #include <Windows.h> #include <CommDlg.h> @@ -160,7 +161,7 @@ void AppImplWinRT::getFolderPath( const fs::path &initialPath, std::vector<std: { if (folder) { - f(fs::path(toUtf8(folder->Path->Data()))); + f( fs::path( msw::toUtf8String( folder->Path->Data() ) ) ); } else { @@ -192,7 +193,7 @@ void AppImplWinRT::getOpenFilePath( const fs::path &initialPath, std::vector<st { if (file) { - f(fs::path(toUtf8(file->Path->Data()))); + f( fs::path( msw::toUtf8String( file->Path->Data() ) ) ); } else {