mirror of
				https://github.com/yuzu-emu/yuzu.git
				synced 2025-11-04 08:43:43 +00:00 
			
		
		
		
	string_util: Implement buffer to UTF-16 string helper function
Needed as most all software keyboard functions use fixed-length UTF16 string buffers.
This commit is contained in:
		
							parent
							
								
									7901de2b75
								
							
						
					
					
						commit
						c70529c1ec
					
				@ -214,6 +214,15 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t
 | 
			
		||||
    return std::string(buffer, len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::u16string UTF16StringFromFixedZeroTerminatedBuffer(const char16_t* buffer,
 | 
			
		||||
                                                        std::size_t max_len) {
 | 
			
		||||
    std::size_t len = 0;
 | 
			
		||||
    while (len < max_len && buffer[len] != '\0')
 | 
			
		||||
        ++len;
 | 
			
		||||
 | 
			
		||||
    return std::u16string(buffer, len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* TrimSourcePath(const char* path, const char* root) {
 | 
			
		||||
    const char* p = path;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -66,6 +66,14 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) {
 | 
			
		||||
 */
 | 
			
		||||
std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Creates a UTF-16 std::u16string from a fixed-size NUL-terminated char buffer. If the buffer isn't
 | 
			
		||||
 * NUL-terminated, then the string ends at the greatest multiple of two less then or equal to
 | 
			
		||||
 * max_len_bytes.
 | 
			
		||||
 */
 | 
			
		||||
std::u16string UTF16StringFromFixedZeroTerminatedBuffer(const char16_t* buffer,
 | 
			
		||||
                                                        std::size_t max_len);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's
 | 
			
		||||
 * intended to be used to strip a system-specific build directory from the `__FILE__` macro,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user