[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Source code for google.appengine.api.search.unicode_util
#!/usr/bin/env python## Copyright 2007 Google Inc.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#"""Utility methods related to Unicode."""def_Unicode32(s):"""Tells whether a string contains 32-bit Unicode characters. Args: s: a string, possibly of unicode type. Returns: True if there are 32-bit characters, False otherwise. """ifisinstance(s,unicode):returnany(ord(ch)>=0x10000forchins)else:returnFalsedef_SplitUnicode(s):"""Generator function to limit characters to UTF-16. Converts all characters in the Supplementary Planes (> 64K) to surrogate pairs. Leaves lower codepoints unchanged. See https://wikipedia.org/wiki/UTF-16#U.2B10000_to_U.2B10FFFF Args: s: a unicode string, possibly containing 32-bit characters Yields: Characters of the translated string. """forchins:iford(ch)<0x10000:yieldchelse:twentybit=ord(ch)-0x10000yieldunichr(0xD800+(twentybit>>10))yieldunichr(0xDC00+(twentybit&0x3FF))
[docs]defLimitUnicode(s):"""Replaces 32-bit Unicode characters with surrogate pairs. Returns a version of the string argument with all Unicode characters above 0xFFFF (those from the Supplementary Plane) replaced with the appropriate surrogate pairs. If there are no such characters, returns the same string instance. See https://wikipedia.org/wiki/UTF-16#U.2B10000_to_U.2B10FFFF Args: s: a string, possibly of unicode type, to be converted if necessary. Returns: Unicode string with surrogate pairs, or the argument unmodified. """if_Unicode32(s):returnu''.join(_SplitUnicode(s))else:returns
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]