Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace more %xy in mission names #1166

Merged
merged 3 commits into from
Jun 20, 2019
Merged

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Jun 19, 2019

When merged this pull request will:

  • adds CBA_fnc_decodeHTML

  • function replaces more %xy than %20 / space

  • Is there a difference between HTML and HTML URL? I am not sure about the function name.

  • Function doesn't work as is, because some functions are not defined in mission namespace in the briefing. Needs some fixing.

  • Will we do the complete HTML character list?

@commy2 commy2 added this to the 3.12 milestone Jun 19, 2019
@bux
Copy link
Contributor

bux commented Jun 19, 2019

@veteran29
Copy link
Member

veteran29 commented Jun 19, 2019

Is there a difference between HTML and HTML URL? I am not sure about the function name.

IMO it would fit more to name this fnc_urlDecode / fnc_decodeURL you don't use percent encoding in HTML, you use this in URLs.

Edit: It's also known as percent encoding... but fnc_decodePercent doesn't sound good at all ^^
https://en.wikipedia.org/wiki/Percent-encoding

@commy2
Copy link
Contributor Author

commy2 commented Jun 19, 2019

No DLL's in CBA, bux.

@commy2 commy2 removed the WIP label Jun 20, 2019
@commy2 commy2 merged commit e02e5cb into master Jun 20, 2019
@commy2 commy2 deleted the replace-HTML-displayed-missionNames branch June 20, 2019 22:55
@commy2 commy2 restored the replace-HTML-displayed-missionNames branch June 20, 2019 22:55
@commy2 commy2 deleted the replace-HTML-displayed-missionNames branch June 20, 2019 22:55
@@ -10,3 +10,222 @@
#endif

#include "\x\cba\addons\main\script_macros.hpp"

#define UTF8_TABLE [\
["%21","!"],\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just ascii keycodes
https://community.bistudio.com/wiki/toString

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have any good way to translate i.e. %e2%80%98" using toString?

Copy link
Contributor Author

@commy2 commy2 Jun 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this:

missionName
// "%c2%ac%c2%ae%c2%af%c2%b0%c2%b1%c2%b2%c2%b3%c2%b4%c2%b5%c2%b6%c2%b7%c2%b8%c2%b9%c2%ba%c2%bb%c2%bc%c2%bd%c2%be%c2%bf"

missionName call CBA_fnc_decodeURL
// "¬®¯°±²³´µ¶·¸¹º»¼½¾¿"

toString (missionName splitString "%" apply {call compile format ["0x%1", _x]} apply { _x})
// "¬®¯°±²³´µ¶·¸¹º»¼½¾¿"

So it is not exactly the same as ASCII codes. It seems to follow the UTF-8 conversion table instead:
https://www.w3schools.com/tags/ref_urlencode.asp
Except that % is encoded as %% and not %25.

@dedmen
Copy link
Contributor

dedmen commented Jan 4, 2020

Just noticed switching around terrains in the mission list visibly freezes my game.
Booted up the profiler and checked, its cuz fnc_decodeURL is being called 34 times with 20ms runtime each 🤔
each of them calling fnc_replace 217 times.
Even though a total of 0 missions on that terrain contain a % character in the name.. we just use underscores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants