# שגיאת המרת קידוד מ-ASCII-8bit ל-UTF-8 ביומנים

**URL:** <https://meta.discourse.org/t/encoding-conversion-error-from-ascii-8bit-to-utf-8-in-logs/308603>\
**Category:** Bug\
**Tags:** fixed\
**Created:** [19 במאי,‏ 2024,‏ 1:27pm UTC](https://meta.discourse.org/t/encoding-conversion-error-from-ascii-8bit-to-utf-8-in-logs/308603 "2024-05-19T13:27:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [19 במאי,‏ 2024,‏ 3:13pm UTC](https://meta.discourse.org/t/encoding-conversion-error-from-ascii-8bit-to-utf-8-in-logs/308603/2 "2024-05-19T15:13:59Z")

</div>

There seems to be an issue with a specific web crawler; it should not affect you. 🤔

> <https://github.com/discourse/discourse/blob/main/lib/middleware/request_tracker.rb#L187-L194>

Here, there is an issue with encoding the crawler user agent to UTF-8, as it contains an invalid byte.  
`scrub` is supposed to do that. Maybe using [`:undef`](https://apidock.com/ruby/String/encode) parameter can help here:  
`user_agent.encode("utf-8", :undef => :replace)`

![image](https://global.discourse-cdn.com/meta/original/4X/a/b/2/ab29fd5f818f4849b0534bd1a8e753369d6bd52c.png)

```ruby
[51] pry(main)> string = "hello \xa1\x28world\x29".force_encoding("ASCII-8BIT")
=> "hello \xA1(world)"
[52] pry(main)> string.encode('utf-8')
Encoding::UndefinedConversionError: "\xA1" from ASCII-8BIT to UTF-8
from (pry):52:in `encode'
[53] pry(main)> string.encode('utf-8', :undef => :replace)
=> "hello �(world)"

```

---

_[View the full topic](https://meta.discourse.org/t/encoding-conversion-error-from-ascii-8bit-to-utf-8-in-logs/308603)._
