Coder Social home page Coder Social logo

Can we support DownloadFileFromText with charset parameter or by default supporting special characters about blazordownloadfile HOT 21 CLOSED

arivera12 avatar arivera12 commented on August 22, 2024
Can we support DownloadFileFromText with charset parameter or by default supporting special characters

from blazordownloadfile.

Comments (21)

stevanuswijaya avatar stevanuswijaya commented on August 22, 2024 1

Here is the test json, I had same issue with it. Let me know if you need more information.
test data.zip

Sorry for late reply, I think we have a huge time difference and I was really busy at work :)

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024 1

Install-Package BlazorDownloadFile -Version 2.1.6

encoderShouldEmitUTF8Identifier is now false as default please remember turning this option true when downloading the csv file.

from blazordownloadfile.

stevanuswijaya avatar stevanuswijaya commented on August 22, 2024 1

It's working properly now! Thanks for the help!

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Seems weird to me, the DownloadFileFromText should be able to support all characters since it's utf-8 but not every charset maybe in the same encoding format when reading from any source.

As you can see this extension method

public static string ToBase64Encode(this string plainText)

Encodes all text to bytes using utf8, are you sure your problem exactly or may reside over there?

I don't think this should be a JavaScript issue at all but maybe from c# encoding since JavaScript downloads the file as-is without any encoding or conversions.

If you can send me a repro I may fix it.

Can you confirm that before sending the text to the DownloadFileFromText method the text is correctly encoded and they get interpreted incorrectly after downloading and opening the file?

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

That error can also occur with the text editor and how does it's interprets the characters.

What software you are using to open the csv file? MS Excel?

from blazordownloadfile.

stevanuswijaya avatar stevanuswijaya commented on August 22, 2024

As you can see here, when I call BlazorDownloadFile, the string was still okay.

image

I'm using MS Excel to open the csv file.

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Ok, good can you check which charset enconding is your MS Excel opening the csv file?

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Can you check if the .csv file opened in notepad to see if it's encoded wrongly?

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Can you check if the .csv file opened in notepad to see if it's encoded wrongly?

If opened in notepad is wrong then I will expose the charset encoding as an option with a default value to prevent breaking changes on the api.

Please let me know asap.

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

I would like also to know if after using the extension to base64encode does your encoding gets broken.

from blazordownloadfile.

stevanuswijaya avatar stevanuswijaya commented on August 22, 2024

I opened the bad the file with notepad++.

image

The encoding: UTF-8
image

But in excel:

image

The good file after changing the BlazorDownloadFile script in notepad++:
image

Encoding: UTF8-BOM
image

In excel:

image

from blazordownloadfile.

stevanuswijaya avatar stevanuswijaya commented on August 22, 2024

I tried to change the base64encode this code instead as you instructed

image

and we still get same bad result

image

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Thanks for the investigation and the input I will take a deeper look on it.

Can you share any sample data for me in json format?

So I can use it has a test case?

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Wait a minute I read this in a hurry, in notepad++ the file opened ok. But in excel is wrong but after changing the encoding file format in notepad++ the excel read ok?

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

This seems to be an issue with excel on how interprets csv filed but not rather with this library and the download process.

Reference:
https://stackoverflow.com/questions/6002256/is-it-possible-to-force-excel-recognize-utf-8-csv-files-automatically

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Please upload for me a test json data so I can retest those special chars there seems to be a workaround this in the reference link.

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

New release
Install-Package BlazorDownloadFile -Version 2.1.4

@stevanuswijaya I didn't had time to test your attached file data but it should work for you out of the box.

I am in a hurry.

Please try out this new package version.

Take a look of this commit for more details.

I turned on by default encoderShouldEmitUTF8Identifier so this should work for you out of the box.

Please try it out and give me your feedback when ever it's possible.

from blazordownloadfile.

stevanuswijaya avatar stevanuswijaya commented on August 22, 2024

Hi

Unfortunately, I still got same problem.

image

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Ok, give me a time so I can retest this with more free time, reopening.

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

It's seems I got it working now.
image

from blazordownloadfile.

arivera12 avatar arivera12 commented on August 22, 2024

Install-Package BlazorDownloadFile -Version 2.1.5

Please give me feedback if this does work for you properly now!

from blazordownloadfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.