String from filename showing %20 where spaces are in the name, unwanted - ios

I'm bringing in images with names that contain spaces, English names and Chinese names, and using those filenames to create strings that are presented beneath their images.
This worked fine until I started putting Chinese into the image file names.
Now, unfortunately all spaces are coming in as
%20
and an example of Chinese looks like this:
%E7%99%BE%E9%A6%99
I have Chinese Simplified installed, and setup in internalisation settings of the project in Xcode... but somehow I'm missing something. Which isn't the first time, and won't be the last.
What do I need to do to make Unicode work?

The path is urlencoded if you urldecode the path spaces should turn out fine
For Swift 3:
substring.removingPercentEncoding
For Swift 2.3:
substring.stringByRemovingPercentEncoding

Related

HexaPDF glyphs missing as of Version 0.20.2

I'm using HexaPDF to read a file with an AcroForm and fill in this form's fields using the following code:
#acro_form.field_by_name(fieldname).field_value = value
Up until version 0.20.1 this worked fine. As of version 0.20.2, I get this error: HexaPDF::Error (Glyph for "2" missing) on trying to generate the document. The glyphs for all numbers, and for all lower case letters except a, b, and c cause this respective error.
This problem only occurs in my dev setup on Windows 11, not on Linux.
#gettalong or anyone else who might be able to help: Thx in advance!
With the help of #gettalong I figured out the problem:
Some of the text in data/hexapdf/encoding/glyphlist.txt appears to be automatically processed by Windows, inserting line and page breaks in this file which should not be there, and causing other changes to the file's encodings.
I resolved it by editing the above file as follows:
Remove extra paragraph and line breaks and potential invisible characters on entries for controlFF, controlVT and controlSO
Set codes (the part after the semicolon) for controlSUB to blank
Remove blank space on "controlBEL; ", changing this line to "controlBEL;"
Ensure there is a blank space on space, i.e. the line must be "space; ", not "space;" and ensure there is no additional invisible character there.
Save the file and restart server.

Revit Ironpython Shell - Parsing a list of filenames with a number after a backslash in the path

I want to read in a list of files (inc path) from either a spreadsheet or a text file for some downstream processing. The list has been generated as a log from another process and the path includes a 2 digit year folder followed by a project number folder as follows:
\\servername\projects\19\1901001\project files\filetobeprocessed.abc
The problem is as soon as the above string is read in, it is interpreted as
\\servername\\projects\x019\x01901001\\project files\x0ciletobeprocessed.abc
Which then means that I cannot use the path to access the file.
Assigning the path string to a variable, I have tried:
thePath = repr(pathreadfromfile)
After assigning the path string I have tried fixing the string using
thePath.replace('\x0','\\')
thePath.replace('\\x0','\\')
thePath.replace(r'\x0','\\')
Nothing seems to fix the path so that it can be used to open the file.
I can't find anything in either python or Ironpython that suggests a fix for this programatically. I know that you can fix this is the path is known within the code by using r'' to use raw text to create the path.
Any help appreciated
Obviously, the backslash \ is interpreted as an escape character.
For a really simple solution, hopefully the simplest, I would suggest using forward slash / for all your path separators instead of backslash.
If you really need the backslash somewhere further down the road, you can replace them back again.

Bundle display name missing space characters

When I give Bundle display name with space as "A B C D", I get the app name as "ABCD". This happens only on the iOS 11.I tried override name"CFBundleDisplayName" in my InfoPlist.string and use special unicode character \U00A0 (No-break space) and it doesn't help me.
This is because of a change Apple made in iOS 11 for truncating for longer app names. If the name is longer than 12 characters, the spaces will be removed. Otherwise, they'll still exist.
For example, Guide book app will become Guidebookapp, but Gui boo app will stay as Gui boo app.
Using unicode   (FIGURE SPACE) works because it isn't an ascii space. I would be hesitant to use this as a solution because it seems reasonable that Apple would "fix" this bug and remove   for apps with names longer than 12 characters.
https://forums.developer.apple.com/thread/77832
I have the same issue. Only on iOS 11. On lower iOS version this issue isn't appeared.
I resolved this with:
Open info.plist as Source code(right click, open as...)
Find CFBundleDisplayName
Replace normal space with unicode  
That's all. After that display name shows with space.
UPDATED:
  works only when typed in *.plist. Can't be inserted in Display name in Xcode project settings;
It works for me when I replace space with FIGURE SPACE   in InfoPlist.strings manually or with a script.
Edit info.plist as source code but use instead of  .
  looks like 2 spaces.
In my case this value was missing from info.plist file so I just add the following to it:
<key>CFBundleDisplayName</key>
<string>$(PRODUCT_NAME)</string>
Give More Space in Bundle Display Name
like
abc def abcdef

NSLocalizedString in Spritekit SKLabelNode

I've been searching all over the internet and there doesn't seem to be a clear explanation on how to localize strings using SpriteKit. Only seeing tutorials for people using the interface builder, but all I really want is, imagine this:
I have an SKLabelNode called label. And I define the text like:
labl.text = NSLocalizedString("titleOfTheScreen",nil)
So basically what I think I have to do is add the new language in the Project settings. Then, I add a new Strings file called Localized, and add it to the new folder.
But what happens to my English language? There's no file for the original one
First you have to add a Strings File:
Then open the project settings and add a new language:
Mark your added strings file as target:
Find the newly added localising file. (English is automatically added)
From your screenshots I can see that you have "File.strings" file. You should have created "Localizable.strings" file.
Also, I can see that you have the (Base), (English) and (German) strings version. Why do you think English is not there?
In each of the files you should put strings like that:
"titleOfTheScreen" = "blah-blah";
Replace "blah-blah" with the proper translation in each of the strings files. It's important to note that the semi-colon at the end of the lines in strings files are mandatory, otherwise Xcode would issue some really funny error messages. This is easy to overlook if you're programming in Swift and trailing semi-colons are not mandatory.

PathForResource with wildcard for thefilename parameter

I know this sounds weird, but is it possible to use wildcard for theFileName parameter?
NSBundle.mainBundle().pathForResource(theFileName, ofType: "csv", inDirectory: directory)
Because I have several files that follow particular naming scheme. Basically, the first part of the filename is English and the second part is French. They are separated by three dashes. For example, "West---Ouest.csv". There is REST service the provides English part of the file name. However, it does not provide French. So what I like to do is use the English part and replace the french part with say asterisk. So, the value for filename parameter would be - "West---*". I tested asterisk, but seems that pathforresource does not work with that. Any work around to this problem?
Edit: English part is unique, so there's no file with the same english name.
No, there isn't. This is not a dynamically created file; you put it into your project by hand before building. Its name is absolutely known to you, and you must use its absolute name. Of course, you are free to change its name when you put it into your project. And if you have several files, you are free to form the name dynamically in code when your app runs — after all, theFileName can be created on the fly however you like. For example, in my app I have files called image1.jpg, image2.jpg, and so on, so I start with a number, form the name, and fetch the image.

Resources