standards

Convert JIS X 208 code to UTF-8 in Python

陌路散爱 提交于 2021-02-20 05:13:09
问题 Let's say I have this Kanji "亜" which is represented in JIS X 208 code in hex form: 0x3021. I want my Python program to convert that code into its UTF-8 form E4BA9C so that I can pass that string (URL-encoded) into my url like this http://jisho.org/api/v1/search/words?keyword=%E4%BA%9C I'm using Python 2.7.12 but I'm open to Python 3 solution as well 回答1: These are accessed under ISO 2022 codec. >>> '亜'.encode('iso2022_jp') b'\x1b$B0!\x1b(B' If I saw those bytes not framed by the escape

Convert JIS X 208 code to UTF-8 in Python

此生再无相见时 提交于 2021-02-20 05:12:45
问题 Let's say I have this Kanji "亜" which is represented in JIS X 208 code in hex form: 0x3021. I want my Python program to convert that code into its UTF-8 form E4BA9C so that I can pass that string (URL-encoded) into my url like this http://jisho.org/api/v1/search/words?keyword=%E4%BA%9C I'm using Python 2.7.12 but I'm open to Python 3 solution as well 回答1: These are accessed under ISO 2022 codec. >>> '亜'.encode('iso2022_jp') b'\x1b$B0!\x1b(B' If I saw those bytes not framed by the escape

Convert JIS X 208 code to UTF-8 in Python

冷暖自知 提交于 2021-02-20 05:12:13
问题 Let's say I have this Kanji "亜" which is represented in JIS X 208 code in hex form: 0x3021. I want my Python program to convert that code into its UTF-8 form E4BA9C so that I can pass that string (URL-encoded) into my url like this http://jisho.org/api/v1/search/words?keyword=%E4%BA%9C I'm using Python 2.7.12 but I'm open to Python 3 solution as well 回答1: These are accessed under ISO 2022 codec. >>> '亜'.encode('iso2022_jp') b'\x1b$B0!\x1b(B' If I saw those bytes not framed by the escape

Is it safe to pass arguments by reference into a std::thread function?

蹲街弑〆低调 提交于 2021-02-18 09:58:09
问题 #include <thread> #include <string> #include <vector> #include <chrono> using namespace std; void f(const vector<string>& coll) { this_thread::sleep_for(1h); // // Is coll guaranteed to be valid before exiting this function? // } int main() { { vector<string> coll(1024 * 1024 * 100); thread(f, coll).detach(); } // // I know std::thread will copy arguments into itself by default, // but I don't know whether these copied objects are still valid // after the std::thread object has been destroyed

Is there a standard way to sort by a non-english alphabet? For example, the romanian alphabet is “a ă â b c…” [duplicate]

倾然丶 夕夏残阳落幕 提交于 2021-02-08 15:55:16
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: How do I sort unicode strings alphabetically in Python? As a citizen of the Rest-of-the-World, I'm really annoyed by the fact that computers aren't adapted by default to deal with international issues. Many sites still don't use Unicode and PHP is still in the Dark Ages. When I want to sort a list of words or names in romanian I always have to write my own functions, which are hardly efficient. There must be

Is there a standard way to sort by a non-english alphabet? For example, the romanian alphabet is “a ă â b c…” [duplicate]

核能气质少年 提交于 2021-02-08 15:53:48
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: How do I sort unicode strings alphabetically in Python? As a citizen of the Rest-of-the-World, I'm really annoyed by the fact that computers aren't adapted by default to deal with international issues. Many sites still don't use Unicode and PHP is still in the Dark Ages. When I want to sort a list of words or names in romanian I always have to write my own functions, which are hardly efficient. There must be

Default argument and parameter promotions in C

女生的网名这么多〃 提交于 2021-02-08 14:25:04
问题 I was studying about default argument promotions and got stuck at one point. In C 2011 (ISO/IEC 9899:2011), the relevant part seem to be: §6.5.2.2 Function calls ¶6 If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions. If the number of arguments does not equal the number of parameters, the

Default argument and parameter promotions in C

余生长醉 提交于 2021-02-08 14:24:54
问题 I was studying about default argument promotions and got stuck at one point. In C 2011 (ISO/IEC 9899:2011), the relevant part seem to be: §6.5.2.2 Function calls ¶6 If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions. If the number of arguments does not equal the number of parameters, the

What if an object passed into std::swap throws an exception during swapping?

◇◆丶佛笑我妖孽 提交于 2021-02-08 14:16:04
问题 The C++ standard guarantees that std::swap will throw no exception. However, what if an object to swap throws an exception during swapping? Next, how should the caller find an exception has happened? and what measures should the caller take? PS: It is very common that a constructor throws an exception. struct A { A(const A&) { throw 1; } A& operator =(const A&) { throw 2; return *this; } }; int main() { A a1, a2; std::swap(a1, a2); // An exception happened, but the caller doesn't know. // How

What if an object passed into std::swap throws an exception during swapping?

 ̄綄美尐妖づ 提交于 2021-02-08 14:15:41
问题 The C++ standard guarantees that std::swap will throw no exception. However, what if an object to swap throws an exception during swapping? Next, how should the caller find an exception has happened? and what measures should the caller take? PS: It is very common that a constructor throws an exception. struct A { A(const A&) { throw 1; } A& operator =(const A&) { throw 2; return *this; } }; int main() { A a1, a2; std::swap(a1, a2); // An exception happened, but the caller doesn't know. // How