<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 4:</p><p style="white-space: pre-wrap; word-wrap: break-word;">I think that the correct fix is going to be to modify ast_odbc_ast_str_SQLGetData() to retrieve the data in parts, as documented here:</p><p style="white-space: pre-wrap; word-wrap: break-word;">https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function?view=sql-server-2017#retrieving-variable-length-data-in-parts</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">How about a fixed-length data in parts (ex. NCHAR)? Microsoft prohibits to retrieve the data in parts for a fixed-length data.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I think your original solution may be the best (except you should multiply by 4 instead of 3).</p><p style="white-space: pre-wrap; word-wrap: break-word;">The problem is that the drivers are inconsistent and I'm sure they are not even consistent with themselves between releases. When using the "octet length" check, MySQL returns a value that is sufficient to store the bytes in UTF-8, while Microsoft's does not. Multiplying the number of potential characters - while not ideal - is a better solution than potentially adding different logic for each of the ODBC drivers.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Because UTF-8 can require up to 4 bytes per codepoint, I think we can consider the 4x factor as the worst-case scenario for Unicode data.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Alexei - thoughts?</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I think need to add configuration option to res_odbc.conf to deal with Microsoft issue.<br>If option is enabled them 4x, otherwise "octet length". By default disabled.<br>The MSSQL Server 2019 supports UTF-8.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I don't personally feel that it is worth it, but I will bow out of the discussion because I don't know enough about how to deal with Unicode & ODBC.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/12812">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/12812">change 12812</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/12812"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I50e86c8a277996f13d4a4b9b318ece0d60b279bf </div>
<div style="display:none"> Gerrit-Change-Number: 12812 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Boris P. Korzun <drtr0jan@yandex.ru> </div>
<div style="display:none"> Gerrit-Reviewer: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Boris P. Korzun <drtr0jan@yandex.ru> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-CC: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Sun, 08 Sep 2019 16:23:54 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>