<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум Рутокен &mdash; Не верная кодировка полей сертификата]]></title>
	<link rel="self" href="https://forum.rutoken.ru/feed/atom/topic/4076/" />
	<updated>2025-05-10T13:40:21Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.rutoken.ru/topic/4076/</id>
		<entry>
			<title type="html"><![CDATA[Re: Не верная кодировка полей сертификата]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/27901/#p27901" />
			<content type="html"><![CDATA[<p><strong>anzhelatursunova</strong>, здравствуйте.<br />В панели форматирования самый правый значок &quot;Загрузите изображение...&quot;<br />Если возникают сложности, вы можете отправить вопрос на <span class="bbu">hotline@rutoken.ru</span>.</p>]]></content>
			<author>
				<name><![CDATA[Вотинов Александр]]></name>
				<uri>https://forum.rutoken.ru/user/16183/</uri>
			</author>
			<updated>2025-05-10T13:40:21Z</updated>
			<id>https://forum.rutoken.ru/post/27901/#p27901</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Не верная кодировка полей сертификата]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/27900/#p27900" />
			<content type="html"><![CDATA[<p>Как подгрузить фото ?</p>]]></content>
			<author>
				<name><![CDATA[anzhelatursunova]]></name>
				<uri>https://forum.rutoken.ru/user/16743/</uri>
			</author>
			<updated>2025-05-09T11:27:11Z</updated>
			<id>https://forum.rutoken.ru/post/27900/#p27900</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Не верная кодировка полей сертификата]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/21898/#p21898" />
			<content type="html"><![CDATA[<p>Спасибо, с консолью был просто пример, так то нужно вывести в окно винапи<br />Но вы подсказали, что строка в кодировке utf-8<br />Написал функцию перевода, все работает, спасибо<br />Может кому то пригодиться<br /></p><div class="codebox"><pre><code>// Переводим в ANSI
int stringToANSI(std::string src, std::string&amp; strANSI)
{
    int size = MultiByteToWideChar(CP_UTF8, NULL, src.c_str(), src.length(), NULL, NULL);
    if (size == 0)
    {
        return 1;
    }

    std::wstring w_str(size, 0);
    int err = MultiByteToWideChar(CP_UTF8, NULL, src.c_str(), src.length(), &amp;w_str[0], size);
    if (err == 0)
    {
        return 2;
    }

    int strANSI_size = WideCharToMultiByte(CP_ACP, NULL, w_str.c_str(), w_str.length(), NULL, NULL, NULL, NULL);
    if (strANSI_size == 0)
    {
        return 3;
    }

    std::string ANSI_str(strANSI_size, 0);
    err = WideCharToMultiByte(CP_ACP, NULL, w_str.c_str(), ANSI_str.length(), &amp;ANSI_str[0], strANSI_size, NULL, NULL);
    if (err == 0)
    {
        return 4;
    }

    strANSI = ANSI_str;

    return 0;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[regnor]]></name>
				<uri>https://forum.rutoken.ru/user/11725/</uri>
			</author>
			<updated>2023-10-26T06:46:16Z</updated>
			<id>https://forum.rutoken.ru/post/21898/#p21898</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Не верная кодировка полей сертификата]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/21897/#p21897" />
			<content type="html"><![CDATA[<p>Добрый день!<br />Спасибо за внимание к интерфейсу pki-core-cpp!<br />Как оказалось, возвращаемые строки в кодировке utf-8.<br />Этот совет со стековерфлоу решает вашу проблему: <a href="https://stackoverflow.com/a/77225440/2373171">https://stackoverflow.com/a/77225440/2373171</a></p><div class="codebox"><pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#ifdef _WIN32
#include &lt;windows.h&gt;
#include &lt;clocale&gt;
#endif

int main() {
#ifdef _WIN32
  // console UTF-8
  std::setlocale(LC_CTYPE, &quot;.UTF8&quot;);
  SetConsoleOutputCP(CP_UTF8);
  SetConsoleCP(CP_UTF8);
#endif

  std::string str = &quot;&quot;;
  std::cout &lt;&lt; str &lt;&lt; std::endl;

  return 0;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Евгений Мироненко]]></name>
				<uri>https://forum.rutoken.ru/user/8673/</uri>
			</author>
			<updated>2023-10-25T15:43:42Z</updated>
			<id>https://forum.rutoken.ru/post/21897/#p21897</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Не верная кодировка полей сертификата]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/21892/#p21892" />
			<content type="html"><![CDATA[<p>Доброго времени суток<br />Пытался получить владельца сертификата, владелец фирма, название на русском языке, в итоге получаю иероглифы<br />Понятно, что дело в кодировке, но я не пойму как починить, пробовал конвертить в вчары, не помогло<br />В драйвере отображается все нормально<br />Подскажите в чем дело?</p><p>Сделал минимальный пример для демонстрации проблемы, ссылка гугл диск<br /><a href="https://drive.google.com/file/d/1yeNOwzBe2sNok7F88RrDmeP0ODVOg914/view?usp=sharing">https://drive.google.com/file/d/1yeNOwz … sp=sharing</a></p>]]></content>
			<author>
				<name><![CDATA[regnor]]></name>
				<uri>https://forum.rutoken.ru/user/11725/</uri>
			</author>
			<updated>2023-10-25T11:17:26Z</updated>
			<id>https://forum.rutoken.ru/post/21892/#p21892</id>
		</entry>
</feed>
