* @brief Converts @a str to wide string. * * @param[in] str String for conversion. * @param[in] length Length in bytes of one character in output string. * If length is zero, function returns empty string. * * @return Converted string. */
| 396 | * @return Converted string. |
| 397 | */ |
| 398 | std::string toWide(const std::string &str, std::string::size_type length) { |
| 399 | if (!length) { |
| 400 | return ""; |
| 401 | } |
| 402 | |
| 403 | const std::string padding(length - 1, '\0'); |
| 404 | std::string result; |
| 405 | result.reserve(str.length() * length); |
| 406 | for (auto c : str) { |
| 407 | result += c + padding; |
| 408 | } |
| 409 | return result; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * @brief Converts unicode @a bytes to ASCII string. |