Giter VIP home page Giter VIP logo

Comments (7)

guardrex avatar guardrex commented on August 28, 2024 8

@joefeser 👍 I'm way late to the party, but ...

We could detect and strip out the BOM ourselves, but this is a potentially surprising transformation of the blob's original data

It would have been nice though to have an overload .DownloadText(bool stripByteOrderMark), so that the original method would just do the un-"surprising" thing and the overload would allow the dev to explicitly call for stripping the BOM.

from azure-storage-net.

joefeser avatar joefeser commented on August 28, 2024 2

Seriously, 5 months with no comment?

from azure-storage-net.

r-aghaei avatar r-aghaei commented on August 28, 2024 2

I created an extension method DownloadString for CloudBlockBlob and used the same code which is used in WebClient.DownloadString. Here you can find the code: How to get rid of BOM when downloading text from azure blob

from azure-storage-net.

pksorensen avatar pksorensen commented on August 28, 2024

Closed my issue. Found the same issue.

from azure-storage-net.

vinaysh-msft avatar vinaysh-msft commented on August 28, 2024

Apologize for the delay.

DownloadText api is currently a simple utility api that takes the bytes and passes its to corresponding encoder to get a string back. It was not designed to map one to one with File.ReadAllText().

We will evaluate a fix for above issue for our future release. This can only be part of our next breaking change release as it changes the API behavior. For now, you can use the workaround suggested by @rzio

from azure-storage-net.

joefeser avatar joefeser commented on August 28, 2024

@vinaysh-msft If it passed it to the correct encoder, it should have dealt with the BOM correctly and not returned it as part of the string.

from azure-storage-net.

mirobers avatar mirobers commented on August 28, 2024

We have evaluated this issue. When a blob is downloaded using DownloadText(), we apply an encoding to construct a string (by default, we use .NET's UTF-8 implementation). Applying the encoding to the string does not strip out the BOM. We could detect and strip out the BOM ourselves, but this is a potentially surprising transformation of the blob's original data, especially given that the Content-Encoding header might also be specified on the blob with conflicting info.

See also that the same behavior exists in WebClient.DownloadString: http://stackoverflow.com/questions/1317700/strip-byte-order-mark-from-string-in-c-sharp

Note that you can pass your own Encoding implementation that strips out the BOM in the call to GetString() if this behavior is desired.

I am closing this old issue now; feel free to raise another issue if you have additional concerns related to encoding.

from azure-storage-net.

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.