You can use QTextCodec to convert the bytearray to a string:
QString DataAsString = QTextCodec::codecForMib(1015)->toUnicode(Data);
(1015 is UTF-16, 1014 UTF-16LE, 1013 UTF-16BE, 106 UTF-8)
From your example we can see that the string "test"
is encoded as "t\0 e\0 s\0 t\0 \0 \0"
in your encoding, i.e. every ascii character is followed by a \0
-byte, or resp. every ascii character is encoded as 2 bytes. The only unicode encoding in which ascii letters are encoded in this way, are UTF-16 or UCS-2 (which is a restricted version of UTF-16), so in your case the 1015 mib is needed (assuming your local endianess is the same as the input endianess).
Related Posts:
- How to convert QString to int?
- How to change string into QString?
- Windows 7 exception code: 0xc0000409
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- error: expected unqualified-id before ‘if’
- Error: C2228: left of ” must have class/struct/union
- Error “Unterminated conditional directive” in cross-referencing headers
- Linker Error C++ “undefined reference ” [duplicate]
- C++ equivalent of Java’s toString?
- Is there any built-in factorial function in c++?
- C++ struct constructor
- When to use virtual destructors?
- std::string to float or double
- What is difference between Application Buffer and System Buffer
- C++ undefined reference to defined function
- How do I include the string header?
- How to navigate through a vector using iterators? (C++)
- Differences between C++ string == and compare()?
- What does the explicit keyword mean?
- program ended prematurely and may have crashed. exit code 0xc0000005
- How to use _CRT_SECURE_NO_WARNINGS
- Stack Memory vs Heap Memory
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- C++ string to double conversion
- C++ Linked List Node with class
- ‘was not declared in this scope’ error
- What is the difference between const int*, const int * const, and int const *?
- How to convert a single char into an int [duplicate]
- C++ request for member ‘’ in ‘’, which is of non-class type ‘’
- Using O_RDWR vs O_RDONLY | O_WRONLY
- How to implement the factory method pattern in C++ correctly
- c++ array – expression must have a constant value
- getline() does not work if used after some inputs
- Passing a 2D array to a C++ function
- ‘typeid’ versus ‘typeof’ in C++
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- Thread pooling in C++11
- Callback functions in C++
- Reading from text file until EOF repeats last line
- How does std::forward work? [duplicate]
- Examples of good gotos in C or C++
- What is std::move(), and when should it be used?
- Undefined reference to class constructor, including .cpp file fixes
- Deleting a dynamically allocated 2D array
- How to add element to C++ array?
- Difference of keywords ‘typename’ and ‘class’ in templates?
- Error: Jump to case label in switch statement
- What does int & mean
- Split a string into an array in C++
- splitting a string into an array in C++ without using vector
- Remove spaces from std::string in C++
- How to use glOrtho() in OpenGL?
- error: ‘ostream’ does not name a type
- Remove spaces from std::string in C++
- What is the preferred way to include error messages in C++?
- How to Convert a C++ String to Uppercase
- C++ Fractions Class
- #pragma once vs include guards?
- Debug vs Release in CMake
- C++ Remove punctuation from String
- prototype for “….” does not match any in class “…”
- Cannot open Windows.h in Microsoft Visual Studio
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- Reference to non-static member function must be called
- Call to non-static member function without an object argument compiler error
- How can I assign an array from an initializer list?
- I get this error: “glibc detected”
- How can I get and use the header file
in my C++ program? - cin.eof() functionality
- Implementing a tree in C++
- Drawing Circle with OpenGL
- Run-Time Check Failure #2 – Stack around the variable ‘foo’ was corrupted
- How to implement “Press Any Key To Exit”
- Reading and writing binary file
- Converting string to ASCII
- got “cannot appear in a constant-expression” when using template
- C++ ostream and ofstream conversions
- C++ discards qualifiers
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- C++ : Exception occurred in script: basic_string::_S_construct NULL not valid
- How to draw line in OpenGL?
- c++ sizeof( string )
- How can I add reflection to a C++ application?
- operator << must take exactly one argument
- Struct inheritance in C++
- How do I simply compare characters in C++?
- How to Check the Version of my gcc?
- Difference between function arguments declared with & and * in C++
- C++ floating point to integer type conversions
- How to get an average in C++?
- C++: variable ‘std::ifstream ifs’ has initializer but incomplete type
- template argument 1 is invalid (Code::Blocks Win Vista) – i don’t use templates
- invalid use of template name without an argument list
- What is “error C2061: syntax error : identifier “?
- What is the size of sizeof(vector)? C++
- C++ – Print Out Objects From Set
- Why virtual & static keywords aren’t allowed outside class declaration?
- Member function with static linkage
- C++ equivalent of java’s instanceof
- Conversion from ‘myItem*’ to non-scalar type ‘myItem’ requested