Encode "65001: Unicode (UTF-8)" to "932: Japanese (Shift-JIS)"

I am trying to read a .txt file and write it to .csv, the actual data is in utf-8 and I want the data to be encoded to shift-JIS(Japanese). How do I do this?

grafik
Or
grafik
OR
API File.WriteXXX Method

Also let us know whicht TargetFramework is used, For Windows maybe the EncodingProvider is ot register before

Also have a look here for encoding ootb availability

Encoding retrieval e.g.:

1 Like

I am facing this issue:

22.10.3+Branch.master.Sha.def2351dc828ccfbcddb6e9e07c9cf71b5bf55da

Source: Write Text File

Message: One or more errors occurred. (‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) (‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) (‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’))

Exception Type: System.AggregateException

System.AggregateException: One or more errors occurred. (‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) (‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) (‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) —> System.ArgumentException: ‘shift_jis’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’) at System.Text.EncodingTable.InternalGetCodePageFromName(String name)
at System.Text.EncodingTable.GetCodePageFromName(String name)
at System.Text.Encoding.GetEncoding(String name)
at UiPath.Core.Activities.WriteTextFile.<>c__DisplayClass18_0.b__0()
at UiPath.Core.Activities.Retry.<>c__DisplayClass1_0.b__0()
at UiPath.Core.Activities.Retry.Do[ResultType](Func1 action, Int32 timeoutMS, Int32 retryCount) --- End of inner exception stack trace --- at UiPath.Core.Activities.TaskAsyncCodeActivity1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

as mentioned:

have a look there:

I have followed the above solution and used the Invoke Method for encoding.
ReadTextFile->Encoding->us-ascii
WriteTextFile->Encoding->shift_jis

But still my output file data is not encoded to Japanese(Shift-JIS) format instead my data is being written like this:
11?l???t
12???
14???l
15???
which is again “us-ascii” format.

Hi,

If you need to read shift_jis encoded text, perhaps you should set “shift_jis” at Encoding property of ReadTextFile activity.

If possible, can you share your text file? We might be able to check it.

Regards,

I’ve tried shuft_jis but I’ve got this error:
“‘shuft_jis’ is not a supported encoding name.”

I want to read “1252: Western Europian (Windows)” encoded text and write it to a csv in “932: Japanese (Shift-JIS)” encoded format

HI,

Can you try as the following?

Set “Windows-1252” at Encoding property of ReadTextFile
Set “shift_jis” at Encoding property of WriteTextFile

Please note that if there are some characters which the other encoding doesn’t have, it might be “?” character.

And can you share your file? It’s no problem, if dummy data.

Sorry, shuft_jis is my typo. It shoulkd be shift_jis.

Regards,

I’ve tried this:
Set “Windows-1252” at Encoding property of ReadTextFile
Set “shift_jis” at Encoding property of WriteTextFile

but got this error: “‘Windows-1252’ is not a supported encoding name.”

Kindly refer to the attached text file,

data.txt (337 Bytes)

Hi,

Unfortunately, some characters in your file are not contains Shift-JIS character set.
Perhaps you should save this as UTF-8, i think.

Regards,

Does setting the Encoding property of ReadTextFile as “UTF-8” reads that text file in utf-8 format?

Nope, it should be windows-1252. Can you try the following sample? This outputs read your text as windows-1252 then output it to UTF-8 and Shift-JIS.

Sample20221202-3net.zip (2.6 KB)

Regards,

It’s still not encoded to shift-jis.

HI,

It’s impossible because some characters in your file are not contains Shift-JIS character set.
Shift-JIS has about 9000 characters but doesn’t include some of Windows-1252.

Regards,

Understood. Thanks a lot.

Hi.
Shift-JIS encoding format is not supported in windows, hence I tried with “932” encoding format and the Japanese characters has been read and written to csv.

Hi,

CP932 is mostly(99.9%) same as “Shift_JIS” and .net supports both encoding. Can you share your situation in details?

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.