<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="204923" data-post-id="204923">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="al2o3cr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/120/3457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  al2o3cr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>FWIW, the byte <code>0xFA</code> represents a “middle dot” character ( · ) on the old DOS code page 437.</p>
<p>Untangling old data like this is exceptionally difficult in general; I once had to migrate a database that had been storing whatever native character set was sent by clients (due to an old IE6 bug) and thus had everything from Arabic to Cyrillic ISO-8859 codepages mixed together. We had to hand-code a translation function from “customer country” to “likely character set” to deal with all that mess…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="204923" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/solve-can-i-solve-in-invalid-byte-0xfa-in-119-199-error-in-ecto/37830/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-204923" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="204923"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="217786" data-post-id="217786">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peprog" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peprog/120/22725_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peprog
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="kip" data-post="9" data-topic="37830">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/48/1440_2.png" class="avatar"> kip:</div>
<blockquote>
<p>valid</p>
</blockquote>
</aside>
<p>Hello, I have almost the same issue.<br>
I’m trying to encode a 5 digit number with sha256 and set as a parameter in Guardian JTW token.<br>
I get this error:</p>
<p>** (exit) an exception was raised:<br>
** (Jason.EncodeError) invalid byte 0xE6 in &lt;&lt;39, 230, 80, 212, 221, 113, 28, 70, 32, 224, 187, 31, 151, 119, 135, 64, 98, 182, 156, 148, 203, 167, 9, 232, 6, 132, 32, 193, 154, 195, 82, 14, 255, 75, 121, 167, 68, 155, 55, 111, 108, 62, 12, 85, 98, 82, 225, 222, 11, 147, …&gt;&gt;<br>
(jason 1.2.2) lib/jason.ex:150: Jason.encode!/2<br>
(jose 1.11.1) src/jwt/jose_jwt.erl:89: :jose_jwt.to_binary/1<br>
(jose 1.11.1) src/jwt/jose_jwt.erl:172: :jose_jwt.sign/3<br>
(guardian 2.1.1) lib/guardian/token/jwt.ex:259: Guardian.Token.Jwt.create_token/3<br>
(guardian 2.1.1) lib/guardian.ex:765: Guardian.returning_tuple/1<br>
(guardian 2.1.1) lib/guardian.ex:594: Guardian.encode_and_sign/4<br>
(guardian 2.1.1) lib/guardian/plug.ex:204: Guardian.Plug.sign_in/5</p>
<p>After I added : encrypted = String.chunk(encrypted, :valid) the I get this error:</p>
<p>Request: POST /api/user/authenticate/mobile<br>
** (exit) an exception was raised:<br>
** (Jason.EncodeError) invalid byte 0xAC in &lt;&lt;172, 255&gt;&gt;<br>
(jason 1.2.2) lib/jason.ex:150: Jason.encode!/2<br>
(jose 1.11.1) src/jwt/jose_jwt.erl:89: :jose_jwt.to_binary/1<br>
(jose 1.11.1) src/jwt/jose_jwt.erl:172: :jose_jwt.sign/3<br>
(guardian 2.1.1) lib/guardian/token/jwt.ex:259: Guardian.Token.Jwt.create_token/3<br>
(guardian 2.1.1) lib/guardian.ex:765: Guardian.returning_tuple/1<br>
(guardian 2.1.1) lib/guardian.ex:594: Guardian.encode_and_sign/4<br>
(guardian 2.1.1) lib/guardian/plug.ex:204: Guardian.Plug.sign_in/5</p>
<p>Many invalid chars are gone but Looks like still there are some invalid chars remaining.<br>
What do you recommend?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="217786" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/solve-can-i-solve-in-invalid-byte-0xfa-in-119-199-error-in-ecto/37830/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-217786" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="217786"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="217816" data-post-id="217816">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="al2o3cr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/120/3457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  al2o3cr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="peprog" data-post="13" data-topic="37830">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peprog/48/22725_2.png" class="avatar"> peprog:</div>
<blockquote>
<p>After I added : encrypted = String.chunk(encrypted, :valid) the I get this error:</p>
</blockquote>
</aside>
<p>Two things:</p>
<ul>
<li><code>String.chunk</code> returns a list with two binaries (“valid” and “invalid” characters), but this passes them BOTH along to be serialized to JSON, thus the error</li>
<li><em>dropping</em> the characters wouldn’t be desirable anyways - since you mention the value is calculated with sha256, that’d be like using scissors to trim a big floppy disk to fit in a small disk drive</li>
</ul>
<p>The values in JSON need to be valid UTF-8; if you’re trying to pass arbitrary binary data, consider using an encoding format like hexadecimal (<code>34f89e4c23a0d</code>) or base64. Elixir supports them through the <a href="https://hexdocs.pm/elixir/Base.html#content" rel="nofollow"><code>Base</code></a> module in stdlib.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="217816" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/solve-can-i-solve-in-invalid-byte-0xfa-in-119-199-error-in-ecto/37830/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-217816" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="217816"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>