# “Unable to translate bytes \[...\] at index 0 from specified code page to Unicode.” error in .NET Core applications

**URL:** <https://community.cdata.com/t/unable-to-translate-bytes-at-index-0-from-specified-code-page-to-unicode-error-in-net-core-applications/549>\
**Category:** Editions\
**Tags:** codepages, article, ado.net, net-core, encoding, charset\
**Created:** [December 4, 2023, 9:20pm UTC](https://community.cdata.com/t/unable-to-translate-bytes-at-index-0-from-specified-code-page-to-unicode-error-in-net-core-applications/549 "2023-12-04T21:20:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hesjona\_H](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@Hesjona\_H](https://community.cdata.com/u/Hesjona_H)\
**Post date:** [December 4, 2023, 9:21pm UTC](https://community.cdata.com/t/unable-to-translate-bytes-at-index-0-from-specified-code-page-to-unicode-error-in-net-core-applications/549/1 "2023-12-04T21:21:07Z")

</div>

In .NET Core applications, when handling data with a character set that is not bundled with .NET Standard, you may come across the following error message: _“Unable to translate bytes [..] at index x from specified code page to Unicode”._

To resolve this issue, you will need to install the _System.Text.Encoding.CodePages_ dependency

- _Install-Package System.Text.Encoding.CodePages_

, and add the following line of code to your application at the start of your code:

_System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);_

In the following example, I have used the CData [ADO.NET](http://ADO.NET) Provider for Amazon Marketplace to create a connection to our Japanese Amazon Marketplace account in Entity Framework Core 6.0 (please consult the “Getting Started with EFCore” section of the driver’s documentation: [https://cdn.cdata.com/help/ONJ/ado/pg\_efCoreOverview.htm](https://cdn.cdata.com/help/ONJ/ado/pg_efCoreOverview.htm) ).

The API’s charset is _charset=Windows-31J:_

 ![8cfef000-8998-49d6-a954-9775a9747bfa.png](https://us1.discourse-cdn.com/cdata/original/2X/b/b25dba41b8d2f7080c524ceedf9b45e613ae2ee8.png)

This character encoding isn’t supported by default in .NET Core, hence the error:

 ![830afb39-10b9-47c6-aa04-b76a016bdae7.png](https://us1.discourse-cdn.com/cdata/original/1X/99c9386a0395912bed867f5d32e4254811376bd4.png)

For more information about supported code page encodings in .NET Core, please refer to Microsoft’s documentation: [https://learn.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=net-8.0#remarks](https://learn.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=net-8.0#remarks)

In order to retrieve all the data, I added the dependency and registered the encoding:

 ![9dbb00d2-d77c-4c5b-91cd-aa98ae627b40.png](https://us1.discourse-cdn.com/cdata/original/1X/d4472ed6e064f8ba5af3d506855efe68bb46b9a7.png)

Please reach out to [support@cdata.com](mailto:support@cdata.com) if you run into any issues.
