WPF Pack URIs use three consecutive commas, for example:
pack://application:,,,/myFolder/myPic.bmp
Is the ,,,
part supposed to mean anything? Is it just a delimiter? Can anything go between the commas?
A URI is composed of a scheme, authority, and path1.
For example, take the http
URL of this web page:
https://stackoverflow.com/questions/16256056/commas-in-wpf-pack-uris
scheme = https://
authority = stackoverflow.com
path = /questions/16256056/commas-in-wpf-pack-uris
pack
URIsThe same applies to your pack
URI:
pack://application:,,,/myFolder/myPic.bmp
scheme = pack://
authority = application:,,,
path = /myFolder/myPic.bmp
What's unusual here, is that the authority part consists of an encoded representation of another URI. That other URI looks like this:
application:///
scheme = application://
authority =
path = /
It refers to a "package" – specifically, to the package of resource files of the current application. From the documentation page you already linked:
WPF supports two authorities: application:/// and siteoforigin:///. The application:/// authority identifies application data files that are known at compile time, including resource and content files. The siteoforigin:/// authority identifies site of origin files.
In order to be used as the authority component of the pack
URI, it needs to be encoded so that its slashes aren't misinterpreted as belonging to the path component of the pack
URI.
The way they chose to encode it, is by replacing slashes with commas.
From the same documentation page:
Note
The authority component of a pack URI is an embedded URI that points to a package and must conform to RFC 2396. Additionally, the "/" character must be replaced with the "," character, and reserved characters such as "%" and "?" must be escaped. See the OPC for details.
1) Plus potentially a query and fragment, but those aren't relevant here.
The answer is on the page you linked to,
- Authority:
application:///
and
... Additionally, the "/" character must be replaced with the "," character, and reserved characters such as "%" and "?" must be escaped. See the OPC for details
So
Is the
,,,
part supposed to mean anything?
It's a substitute for ///
Can anything go between the commas?
No.
Correction: The OPC (Open Packaging) link leads to ECMA-376 and that contains examples likepack://http%3c,,www.openxmlformats.org,my.container/a/b/foo.xml
but afaik that does not apply to WPF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With