ResourceLoader returns empty strings - windows-runtime

I am trying to use a *.resw file in my UWP app to store localized strings. I am loading these strings through ResourceLoader.GetString() and am placing them in a MessageDialog for presentation to the user, but no matter what I do the return value of GetString() is an empty (zero-length) string. I am following the SDK sample for localization, but am not getting the expected response.
The string I am trying to use is of the format InvalidAssemblyDialog.Message.

As it turns out this problem was due to my using dots in the keys for my strings in the *.resw file. Dots are reserved, and my usage of them was causing name-resolution errors. In the case of the example above, I changed it to InvalidAssemblyDialog_Message.

Here the documentation says "." characters should be replaced with "/" when resources are queried from code.
If a resource name is segmented (it contains "." characters), then replace dots with forward slash ("/") characters in the resource name. Property identifiers, for example, contain dots; so you'd need to do this substition in order to load one of those from code.

Related

Deal with long numbers in scientific notation in json string - Freemarker

I have a json string which contains a long number but in scientific notation (like 1.559101974041E12 instead of 1559101974041). Due to this, I am not able to parse it using ?eval as this value must be in double quotes in order to get parsed.
I thought of one solution like putting double quotes around them using regex and get them evaluated. After that, use some free marker method to convert value into long. But this solution is very risky and can alter other values as well.
I'm not sure how your template looks, but if you have variable s that contains the string "1.559101974041E12" (the quotation marks aren't part of the string value itself), then you can parse it like s?number. s?eval doesn't work because scientific notation is not part of the FreeMarker syntax (but ?number can parse more formats).
If you will re-print the number in the template, note that depending on locale and configuration settings, it might will look like 1,559,101,974,041. You can prevent that with ?c (for example like ${s?number?c}), in which case it will always look like 1559101974041.

Split a string in semantic MediaWiki

I want to add a link using existing string in in my wiki page.
This string will be appended to a url to form a complete URL.
This string consists of many words, for example "Crisis Management in International Computing"
I want to split by empty space " " then construct this string: "Crisis+Management+in+International+Computing"
Here is the String variable I have in my wiki page:
{{SUBJECTPAGENAME}}
Note: I have to check first if the string consists of more than one word, as if the string is just one word like this "Crisis" I won't perform split function.
I searched the web and did not find clear semantic to us in order to perform this issue.
Anyone experienced such a matter?
If I understand correctly from the comments, you want to replace all occurrences of space in your string, and replace it with +. That can be done with string functions of the ParserFunctions extension.
If you are running a fairly recent version of MediaWiki (>1.18, check by going to Special:Version), the ParserFunctions extension is bundled with the software. You just need to enable it by adding the following to LocalSettings.php:
require_once "$IP/extensions/ParserFunctions/ParserFunctions.php";
$wgPFEnableStringFunctions = true;
Then you will be able to write e.g.
{{#replace: {{SUBJECTPAGENAME}} |<nowiki> </nowiki>|+}}
Note however that if all you really want is a url version of a page name, you can just use {{SUBJECTPAGENAMEE}} instead of {{SUBJECTPAGENAME}}.
I would recommend you to go for a custom parser function.
Or as a hack, try splitting the string using the arraymaptemplate parser functions coming as part of Semantic Forms.
URL : arraymaptemplate parser function.
You can use an intro template to create the link and use array template to split and add the words to the intro template.
I have not tried it with delimiter character as space, but from the documentation, seems, it should be working using the html encoding for space.

Detecting an invalid file name in WinJS

In .NET, I'd use System.IO.Path.GetInvalidFileNameChars to scan a string containing a filename to validate it does not contain invalid characters.
In WinJS, I can't find the equivalent to this function. Is there somewhere else that these characters could be retrieved? My code is building a string based on some metadata from a file, and I suspect that there may be characters present that will not work when creating a new file (imagine like the "title" of a Microsoft Word docx file for example, where the title could contain : and \ characters that wouldn't be valid file names). I'd like to remove or convert these invalid characters so that the file can be saved without user intervention.
Of course, I could just grab a list from .NET and hard code that, but that doesn't seem nearly as elegant.
My other thought was to expose the functionality from a C# component (and expose it as a WinRT component), but I'd rather not introduce a second run-time just for some simple functions like this if I could help it.
There doesn't seem to be a method in WinJS that does this.
Given the small number of special characters, I'd just hardcode those. To get the list, simply try to rename a file to file?.txt in Windows Explorer. It shows you the list of invalid characters:
\ / : * ? " < > |

How to use the DeployIt's namePattern parameter in the repository/query web-service

I’m trying to use the REST API provided by DeployIt (v3.9) to list all the packages available on a given project.
Thus, I use the GET /repository/query service
So, I’m calling this service with the following URL:
http://[server]/deployit/repository/query?namePattern=my-app&type=udm.DeploymentPackage
Unfortunately, I don’t get anything (just an empty list).
If I remove the namePattern from my URL, then I get a long list of all applications (not only the only I'm interested in).
So it appears that I don’t set correctly the namePattern attribute. In the documentation, they say:
a search pattern for the name. This is like the SQL "LIKE" pattern:
the character '%' represents any string of zero or more characters,
and the character '_' (underscore) represents any single character.
Any literal use of these two characters must be escaped with a
backslash ('\'). Consequently, any literal instance of a backslash
must also be escaped, resulting in a double backslash ('\').
So I tried the following URL:
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=my-app : empty list
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=%my-app%: error 400
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=%25my-app%25 (trying to escape the % character): empty list
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=Applications/my-app/2.0.0 (with a real version): error, character ‘/’ not allowed.
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&namePattern=2.0.0 : I get the list of all applications deployed with a version 2.0.0 (including my my-app), but that's not what I'm looking for (I want all versions available on DeployIt for my-app).
So, what is the correct URL to retrieve the list of deployed applications?
I've solved my problem. In fact, the namePattern only applies to the last part of the Application name, i.e. the version.
Thus, I have to use the parent attribute to retrieve the list of my application:
http://[server]/deployit/repository/query?type=udm.DeploymentPackage&parent=Applications%2Fmy-app&resultsPerPage=-1

How can I populate a query string variable to a text box which contains &,\ and $ in it

I have a variable like say A= drug & medicare $12/$15.
I need to assign it to a text box, but only 'drug' is posted the server. The rest of the data gets truncated.
this.textbox.text= request.querystring["A"].tostring();
The following is not valid for a="foo&bar$12":
http://example.com?a=foo&bar$12
The & symbol is a reserved character, it seperates query string variables. You will need to percent encode a value before sending them to that page.
Also & is a reserved character in HTML/XML. I suggest reading up on percent encoding and html encoding.
I believe you have problems with HTML entities. You need to read up on HTML escaping in your tool of choice. & cannot stand in HTML, since it begins an entity sequence - it needs to be replaced with &. Without specifying at least which toolchain you're using (as per #Richard's comment), we can't really suggest the best way to do it.
EDIT: Now that I reread your question, it seems A is not a variable but a query parameter :) Reading comprehension fail. Anyway, in this case a similar problem exists: & is not a valid character for a query parameter, and it needs URL escaping. Again, how exactly to do it is in the documentation for your toolchain, but in essence & will need to be replaced by %26. Plus sign is also not permitted (or rather it has another meaning); others are tolerated (but there are nicer ways to write them).
That looks more or less like ASP.NET pseudocode, so I'm going to diagnose your problem as the query string needing to be URL encoded. Key/value pairs in the query string are separated by an ampersand (&), and ASP.NET (along with other web platforms) automatically parse out the key value pairs for you.
In this case, the ampersand terminates the value of the "A=..." key/value pair. The problem will be solved if you can URL encode the link that brings the user into your page. If actually using ASP.NET, you can use the HttpUtility.UrlEncode() method for that:
string myValue = Server.UrlEncode("drug & medicare $12/$15");
You'll end up with this querystring instead: A=drug%20%26%20medicare%20%2412%2F%2415