Advertisement
by SherpDaWerp » Thu Dec 03, 2020 3:52 pm
by Imperium Anglorum » Thu Dec 10, 2020 7:39 pm
by Merni » Thu Dec 10, 2020 11:29 pm
Imperium Anglorum wrote:In this API call: https://www.nationstates.net/cgi-bin/ap ... resolution. Can the escapes (eg “) be put into Unicode instead of whatever encoding is currently used?
by Imperium Anglorum » Fri Dec 11, 2020 6:25 am
Merni wrote:Imperium Anglorum wrote:In this API call: https://www.nationstates.net/cgi-bin/ap ... resolution. Can the escapes (eg “) be put into Unicode instead of whatever encoding is currently used?
If it helps, at least the decimal 133 (ellipsis … ) and 145-148 (‘ ’ “ ” smart quotes) appear to be from Windows-1252. Weirdly, there are also 39 (' straight apostrophe) and " (" straight quotes).
org.apache.commons.text.StringEscapeUtils
org.jsoup.parser.Parser
"‘", "'",
"’", "'",
"“", "“",
"”", "”",
"…", "…",
"–", "–",
"—", "—"
by Trotterdam » Fri Dec 11, 2020 9:36 am
Imperium Anglorum wrote:In this API call: https://www.nationstates.net/cgi-bin/ap ... resolution. Can the escapes (eg “) be put into Unicode instead of whatever encoding is currently used?
This looks to be an issue with the contents of that particular resolution as submitted, not with the API in general. The API is correctly reporting the data in the server, that data just happens to be wrong, which is nominally the fault of the player who submitted the resolution rather than of NationStates (although really, it's more that neither of them properly sanitized text made by shoddy Microsoft products).Merni wrote:If it helps, at least the decimal 133 (ellipsis … ) and 145-148 (‘ ’ “ ” smart quotes) appear to be from Windows-1252. Weirdly, there are also 39 (' straight apostrophe) and " (" straight quotes).
HTML entities are supposed to be in Unicode, and usually are (even on NationStates). However, because using Windows-1252 characters as though they were Unicode characters is a common mistake, and because the actual Unicode codepoints that they would replace are used by basically no-one ever, most modern browsers recognize them anyway.Imperium Anglorum wrote:Sadly, I can't find anything in Java which will decode HTML entities to Windows-1252 instead of Unicode.
by Trotterdam » Sat Dec 12, 2020 8:29 am
/* wchar_t can be replaced with uint32_t or whatever else you're using for UTF-32 or UTF-16 data. */
void fix_windows_1252_in_unicode(wchar_t *str)
{
static const wchar_t remap[0x20] =
{0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178};
/* Note: 0x81, 0x8D, 0x8F, 0x90, 0x9D are undefined in the Windows-1252 standard. They can be left unmodified (as above), or replaced with 0xFFFD. */
int i;
for(i = 0; str[i]; i++) if((str[i] | 0x1F) == 0x9F) str[i] = remap[str[i] & 0x1F];
}
s/\xC2\x80/\xE2\x82\xAC/g
# \xC2\x81 undefined
s/\xC2\x82/\xE2\x80\x9A/g
s/\xC2\x83/\xC6\x92/g
s/\xC2\x84/\xE2\x80\x9E/g
s/\xC2\x85/\xE2\x80\xA6/g
s/\xC2\x86/\xE2\x80\xA0/g
s/\xC2\x87/\xE2\x80\xA1/g
s/\xC2\x88/\xCB\x86/g
s/\xC2\x89/\xE2\x80\xB0/g
s/\xC2\x8A/\xC5\xA0/g
s/\xC2\x8B/\xE2\x80\xB9/g
s/\xC2\x8C/\xC5\x92/g
# \xC2\x8D undefined
s/\xC2\x8E/\xC5\xBD/g
# \xC2\x8F undefined
# \xC2\x90 undefined
s/\xC2\x91/\xE2\x80\x98/g
s/\xC2\x92/\xE2\x80\x99/g
s/\xC2\x93/\xE2\x80\x9C/g
s/\xC2\x94/\xE2\x80\x9D/g
s/\xC2\x95/\xE2\x80\xA2/g
s/\xC2\x96/\xE2\x80\x93/g
s/\xC2\x97/\xE2\x80\x94/g
s/\xC2\x98/\xCB\x9C/g
s/\xC2\x99/\xE2\x84\xA2/g
s/\xC2\x9A/\xC5\xA1/g
s/\xC2\x9B/\xE2\x80\xBA/g
s/\xC2\x9C/\xC5\x93/g
# \xC2\x9D undefined
s/\xC2\x9E/\xC5\xBE/g
s/\xC2\x9F/\xC5\xB8/g
by Imperium Anglorum » Sat Dec 12, 2020 9:01 am
import org.apache.commons.text.StringEscapeUtils;
...
String w1252 = "~—¡";
String output = StringEscapeUtils.unescapeHtml4(w1252);
System.out.println(output);
System.out.println(output.chars().mapToLong(Long::valueOf)
.boxed().collect(Collectors.toList()));
by Imperium Anglorum » Mon Dec 14, 2020 10:56 am
by Trotterdam » Mon Dec 14, 2020 3:46 pm
I'm seeing the space on both. The original issue has "<NAME>Anti-Cyberterrorism Act </NAME>", while the repeal has "<NAME>Repeal "Anti-Cyberterrorism Act "</NAME>". Or with the spaces highlighted: "<NAME>Anti-Cyberterrorism Act␣</NAME>" and "<NAME>Repeal "Anti-Cyberterrorism Act␣"</NAME>".Imperium Anglorum wrote:There is a data inconsistency in the NS API.
This resolution declares its name to be <Repeal "Anti-Cyberterrorism Act "> (with space before terminating quote). The title of the repeal target is given as <Anti-Cyberterrorism Act> without ending space.
by Elest Adra » Wed Dec 30, 2020 12:45 pm
by SherpDaWerp » Wed Dec 30, 2020 6:27 pm
Elest Adra wrote:Is it possible to vote on World Assembly resolutions though the API?
by That Crazy Casbah Sound » Wed Dec 30, 2020 6:39 pm
SherpDaWerp wrote:Elest Adra wrote:Is it possible to vote on World Assembly resolutions though the API?
Currently, no. There was a short "discussion" of that a while back (from this post on) but nothing eventuated.
by Trotterdam » Thu Dec 31, 2020 4:55 am
Presumably by using the non-API site, which is perfectly legal so long as you stick to the "one server request per user action" rule, which you really shouldn't have any reason for wanting to exceed when it comes to World Assembly votes.That Crazy Casbah Sound wrote:How does Stately do it then?
by Elest Adra » Thu Dec 31, 2020 5:12 am
That Crazy Casbah Sound wrote:SherpDaWerp wrote:Currently, no. There was a short "discussion" of that a while back (from this post on) but nothing eventuated.
How does Stately do it then?
by Imperium Anglorum » Thu Apr 01, 2021 7:41 am
by Valentine Z » Tue Apr 13, 2021 11:30 am
♪ If you are reading my sig, I want you to have the best day ever ! You are worth it, do not let anyone get you down ! ♪
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
(✿◠‿◠) ☆ \(^_^)/ ☆
♡ Issues Thread ♡ Photography Stuff ♡ Project: Save F7. ♡ Stats Analysis ♡
♡ The Sixty! ♡ Valentian Stories! ♡ Gwen's Adventures! ♡
• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.
by Libertarian Technocrats » Tue Apr 27, 2021 2:05 pm
Valentine Z wrote:Hi there! So I have been looking though the API list a little, and unless I missed something, it would seem like currently there is no way to get the Government Expenditure Budget from API?
For example, you can see the amount alongside % of GDP. Is it possible to get these two values other than just the "govt" call?
Thanks in advance! ♥
PAL 8000: Hello user. You requested "RANDOM FACTS ABOUT THE REPUBLIC OF LIBERTARIAN TECHNOCRATS." Did you know that most nations mistakenly think Libertechan directness is actually rudeness?
by Valentine Z » Sat May 01, 2021 9:33 pm
Libertarian Technocrats wrote:Valentine Z wrote:Hi there! So I have been looking though the API list a little, and unless I missed something, it would seem like currently there is no way to get the Government Expenditure Budget from API?
For example, you can see the amount alongside % of GDP. Is it possible to get these two values other than just the "govt" call?
Thanks in advance! ♥
You can get the % from the publicsector call https://www.nationstates.net/cgi-bin/ap ... blicsector
Just call the gdp and multiply by the percentage.
♪ If you are reading my sig, I want you to have the best day ever ! You are worth it, do not let anyone get you down ! ♪
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
(✿◠‿◠) ☆ \(^_^)/ ☆
♡ Issues Thread ♡ Photography Stuff ♡ Project: Save F7. ♡ Stats Analysis ♡
♡ The Sixty! ♡ Valentian Stories! ♡ Gwen's Adventures! ♡
• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.
by [violet] » Mon May 03, 2021 11:34 pm
SherpDaWerp wrote:Yet another bump on the request to have "amount unbid" available on the deck info query.
i.e. this query would also have an additional field: <UNBID> ... </UNBID> which would have the information available here, at the bottom of the page.
If this is an unfeasible addition for whatever reason, just tell me so I stop bumping the request.
by SherpDaWerp » Tue May 04, 2021 1:00 am
[violet] wrote:SherpDaWerp wrote:Yet another bump on the request to have "amount unbid" available on the deck info query.
i.e. this query would also have an additional field: <UNBID> ... </UNBID> which would have the information available here, at the bottom of the page.
If this is an unfeasible addition for whatever reason, just tell me so I stop bumping the request.
Is this not already available via the "asksbids" shard? Admittedly you do need to total up the individual bids.
I'd prefer not to stick that number into the "info" shard as well, because looking up trades is a relatively heavy query, which we want to perform only when people are actually seeking that data.
by Eluvatar » Thu May 13, 2021 7:39 am
by Valentine Z » Thu May 13, 2021 7:45 am
Eluvatar wrote:Due to recent spammers we've had to add ratelimiting to the posting of dispatches. This applies equally to the dispatches API.
Script authors may need to add delays that were previously unnecessary to their scripts.
As failed attempts count toward the rate limit, I would also advise script authors to update their scripts to back off and wait if they get the error.
♪ If you are reading my sig, I want you to have the best day ever ! You are worth it, do not let anyone get you down ! ♪
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
(✿◠‿◠) ☆ \(^_^)/ ☆
♡ Issues Thread ♡ Photography Stuff ♡ Project: Save F7. ♡ Stats Analysis ♡
♡ The Sixty! ♡ Valentian Stories! ♡ Gwen's Adventures! ♡
• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.
by The Northern Light » Thu May 13, 2021 7:52 am
Eluvatar wrote:Due to recent spammers we've had to add ratelimiting to the posting of dispatches. This applies equally to the dispatches API.
Script authors may need to add delays that were previously unnecessary to their scripts.
As failed attempts count toward the rate limit, I would also advise script authors to update their scripts to back off and wait if they get the error.
<NATION id="the_northern_light">
<ERROR>Your nation is attempting to issue many announcements in a short period of time. Please wait for the international press to catch their breath, then try again.</ERROR>
</NATION>
Home of the WADP, Planet Eras, and the Constibillocode!
by Eluvatar » Thu May 13, 2021 7:58 am
Advertisement
Users browsing this forum: Avrelis, Domais, Giovanniland, Hulldom, Indian Empire, Kractero, Lavianianistorotleste, Lunayria, Mors caloris universi, Romanovskaya, Rusolveq, South Newlandia, Tiami
Advertisement