<html><head></head><body><div dir="auto">Hi Levente,<br><br></div>
<div dir="auto">thanks for clarifying this :) I will add a comment to the method to document the intent and a corresponding test case.<br><br></div>
<div dir="auto">Bests <br></div>
<div dir="auto">Patrick</div>
<div class="gmail_quote" >Am 17. Juni 2019, um 17:35, Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>> schrieb:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="blue">Hi Patrick,<br><br>The name of the method is misleading. The intention was not to change the <br>encoding of the receiver nor to filter out out-of-range bytes but to <br>create a ByteString from a WideString when it only contains byte <br>characters. So, the method will return a string equal to the receiver. The <br>returned string will be a ByteString if an only if #isOctetString returns <br>true.<br>I don't think the conversion in your example would make much sense, <br>because it's not reversible: there's no way to recreate the string from a <br>ByteArray.<br><br>Levente<br><br>On Fri, 14 Jun 2019, patrick.rein@hpi.uni-potsdam.de wrote:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Hi everyone,<br><br> while working on parsing network data I tried to use asOctetString and noticed that it did not yield a ByteString when called on a WideString. Is this the intendended behavior? I would have expected a behavior similar to the one I documented in the test case below. If not I think that the problem simply originates from using #at: which is overridden by WideString. <br><br> Bests,<br> Patrick<br><br> testAsOctetStringFromWideString<br><br>  | rawStringOctet wideStringAsOctet wideString |<br>  rawStringOctet := #[103 114 252 223 101 "The character 16r1fA02 starts here" 0 1 250 2].<br>  wideString := 'grüße' , (String value: 16r1FA02).<br>  wideStringAsOctet := wideString asOctetString asByteArray.<br>  self assert: rawStringOctet equals: wideStringAsOctet.</blockquote></pre><pre class="blue"><br></pre></blockquote></div></body></html>