mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge pull request #4700 from zhaowenlan1779/swkbd-2
applets/swkbd: Add callback support
This commit is contained in:
		
						commit
						536e4de499
					
				
					 9 changed files with 156 additions and 94 deletions
				
			
		|  | @ -4,10 +4,12 @@ | |||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <algorithm> | ||||
| #include <cstddef> | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #include "common/common_types.h" | ||||
| #include "common/swap.h" | ||||
| 
 | ||||
| namespace Common { | ||||
| 
 | ||||
|  | @ -58,6 +60,20 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) { | |||
|     return (begin == end) == (*other == '\0'); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Converts a UTF-16 text in a container to a UTF-8 std::string. | ||||
|  */ | ||||
| template <typename T> | ||||
| std::string UTF16BufferToUTF8(const T& text) { | ||||
|     const auto text_end = std::find(text.begin(), text.end(), u'\0'); | ||||
|     const std::size_t text_size = std::distance(text.begin(), text_end); | ||||
|     std::u16string buffer(text_size, 0); | ||||
|     std::transform(text.begin(), text_end, buffer.begin(), [](u16_le character) { | ||||
|         return static_cast<char16_t>(static_cast<u16>(character)); | ||||
|     }); | ||||
|     return UTF16ToUTF8(buffer); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't | ||||
|  * NUL-terminated then the string ends at max_len characters. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue