Enable smooth edges if utf-8 is supported
965064
def on_unicode_checkbox(self, w=None, state=False):
        """"""
        logging.debug("unicode State is %s", state)

        # Update the controller to the state of the checkbox
        self.controller.smooth_graph_mode = state
        if state:
            self.hline = urwid.AttrWrap(
                urwid.SolidFill(u'\N{LOWER ONE QUARTER BLOCK}'), 'line')
        else:
            self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line')

        for graph in self.graphs.values():
            graph.set_smooth_colors(state)

        self.show_graphs()
1037407
def slugify(value, allow_unicode=False):
    
    value
    if allow_unicode:
        value = unicodedata.normalize('NFKC', value)
    else:
        value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
    value = re.sub(r'[^\w\s-]', '', value).strip().lower()

    return re.sub(r'[-\s]+', '-', value)
1328138
def native_(s, encoding='latin-1', errors='strict'):
    '''
    
    '''
    if PY3:
        out = s if isinstance(s, text_type) else str(s, encoding, errors)
    else:
        out = s.encode(encoding, errors) if isinstance(s, text_type) else str(s)

    return out
252323
function (val) {
        var padding, margin, border;
        val = val.replace(/(padding|margin|border)\-([^:]+):([^;]+);?/gi, function (str, key, name, val) {
            if (val.split(' ').length == 1) {
                switch (key) {
                    case 'padding':
                        !padding && (padding = {});
                        padding[name] = val;
                        return '';
                    case 'margin':
                        !margin && (margin = {});
                        margin[name] = val;
                        return '';
                    case 'border':
                        return val == 'initial' ? '' : str;
                }
            }
            return str;
        });

        function opt(obj, name) {
            if (!obj) {
                return '';
            }
            var t = obj.top , b = obj.bottom, l = obj.left, r = obj.right, val = '';
            if (!t || !l || !b || !r) {
                for (var p in obj) {
                    val += ';' + name + '-' + p + ':' + obj[p] + ';';
                }
            } else {
                val += ';' + name + ':' +
                    (t == b && b == l && l == r ? t :
                        t == b && l == r ? (t + ' ' + l) :
                            l == r ? (t + ' ' + l + ' ' + b) : (t + ' ' + r + ' ' + b + ' ' + l)) + ';'
            }
            return val;
        }

        val += opt(padding, 'padding') + opt(margin, 'margin');
        return val.replace(/^[ \n\r\t;]*|[ \n\r\t]*$/, '').replace(/;([ \n\r\t]+)|\1;/g, ';')
            .replace(/(&((l|g)t|quot|#39))?;{2,}/g, function (a, b) {
                return b ? b + ";;" : ';'
            });
    }
1162899
function utf8End(buf) {
  var r = buf && buf.length ? this.write(buf) : '';
  if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
  return r;
}
1292336
def normalizeGlyphRightMargin(value):
    
    if not isinstance(value, (int, float)) and value is not None:
        raise TypeError("Glyph right margin must be an :ref:`type-int-float`, "
                        "not %s." % type(value).__name__)
    return value
242039
function unwrapEmphasis(accent, state) {
  const markerLength = EMPHASIS[accent].length;
  const { startOffset, endOffset, focusText, texts } = state;
  const change = state.change();
  const focusKey = focusText.key;
  const characters = texts.get(0).charsData.characters;
  const { text } = focusText;
  const leftEmphEdge = getLeftEmphEdge(accent, characters, startOffset);
  const rightEmphEdge = getRightEmphEdge(accent, characters, startOffset, text.length);
  const marker = text.substr(leftEmphEdge, markerLength);

  // no selection
  if (startOffset === endOffset) {
    if (startOffset > markerLength - 1 && startOffset < text.length - markerLength + 1) {
      const leftMarker = text.substr(startOffset - markerLength, markerLength);
      const rightMarker = text.substr(startOffset, markerLength);
      // #1 the cursor is wrapped in markers, delete markers
      if (leftMarker === rightMarker && EMPHASIS_ALL[accent].indexOf(leftMarker) !== -1) {
        change.removeTextByKey(focusKey, endOffset, markerLength).
          removeTextByKey(focusKey, startOffset - markerLength, markerLength).focus();
        return change.state;
      }
    }

    // #2 the cursor on a marker, do nothing
    if (leftEmphEdge < startOffset && startOffset <= leftEmphEdge + markerLength ||
      rightEmphEdge - markerLength + 1 <= startOffset && startOffset < rightEmphEdge + 1) {
      return state

      // #3 the between markers, add markers to the place of the cursor
    } else {
      change.insertText(`${marker}${marker}`).move(-markerLength).focus();
      return change.state;
    }

    // selection
  } else {
    // #4 the selection on the left edge, do nothing
    if ((leftEmphEdge === startOffset || leftEmphEdge + 1 === startOffset) &&
      leftEmphEdge + 1 === endOffset || leftEmphEdge + markerLength === endOffset) {
      return state
    }

    // #5 the selection on the right edge, do nothing
    if ((rightEmphEdge - markerLength + 1 === startOffset ||
        rightEmphEdge - markerLength + 2 === startOffset) &&
      (rightEmphEdge === endOffset || rightEmphEdge + 1 === endOffset)) {
      return state
    }

    // #6 the selection between markers, wrap selection in additional markers
    // (between additional markers there is no current emphasis)
    if (leftEmphEdge + markerLength < startOffset && endOffset < rightEmphEdge - markerLength + 1) {
      change.wrapText(marker, marker).focus();
      return change.state;
    }

    // #7 the selection on markers, delete markers
    if (leftEmphEdge <= startOffset && startOffset <= leftEmphEdge + markerLength &&
      rightEmphEdge - markerLength + 1 <= endOffset && endOffset <= rightEmphEdge + 1) {
      change.removeTextByKey(focusKey, rightEmphEdge - markerLength + 1, markerLength).
        removeTextByKey(focusKey, leftEmphEdge, markerLength).focus();
      return change.state;
    }

    // #8 startOffset on left marker, endOffset between markers,
    // remove accent from the left part of a wrapper
    if (leftEmphEdge <= startOffset && startOffset <= leftEmphEdge + markerLength) {
      change.insertTextByKey(focusKey, endOffset, marker).
        removeTextByKey(focusKey, leftEmphEdge, markerLength).
        moveOffsetsTo(leftEmphEdge, endOffset - markerLength).focus();
      return change.state;
    }

    // #9 startOffset between markers, endOffset on right marker,
    // remove accent from the right part of a wrapper
    change.removeTextByKey(focusKey, rightEmphEdge - markerLength + 1, markerLength).
      insertTextByKey(focusKey, startOffset, marker).
      moveOffsetsTo(startOffset + markerLength, rightEmphEdge + 1).focus();
    return change.state;
  }
}
1351576
function normalize(value, options) {
  var settings = options || {}
  var allowApostrophes = settings.allowApostrophes
  var allowDashes = settings.allowDashes
  var result = (typeof value === 'string' ? value : toString(value))
    .toLowerCase()
    .replace(APOSTROPHE, QUOTE)

  if (allowApostrophes && allowDashes) {
    return result
  }

  if (allowApostrophes) {
    return result.replace(DASH, EMPTY)
  }

  if (allowDashes) {
    return result.replace(QUOTE, EMPTY)
  }

  return result.replace(ALL, EMPTY)
}
917870
def normalize_query(text, encoding='utf-8'):
    '''
    '''
    path = percent_encode_plus(text, encoding=encoding)
    return uppercase_percent_encoding(path)
32385
def _text_to_graphiz(self, text):
        """"""
        dot = Source(text, format='svg')
        return dot.pipe().decode('utf-8')
674828
def get_string_offset(edge):
    """"""
    onset_label = edge.find('labels[@name="SEND"]')
    onset_str = onset_label.xpath('@valueString')[0]
    return int(onset_str)
247487
function _fnGetMaxLenString( settings, colIdx )
	{
		var s, max=-1, maxIdx = -1;
	
		for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
			s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
			s = s.replace( __re_html_remove, '' );
	
			if ( s.length > max ) {
				max = s.length;
				maxIdx = i;
			}
		}
	
		return maxIdx;
	}
1115553
def negotiate_encoding (self):
        """"""
        try:
            features = self.url_connection.sendcmd("FEAT")
        except ftplib.error_perm as msg:
            log.debug(LOG_CHECK, "Ignoring error when getting FTP features: %s" % msg)
            pass
        else:
            log.debug(LOG_CHECK, "FTP features %s", features)
            if " UTF-8" in features.splitlines():
                self.filename_encoding = "utf-8"
59528
function UNICODE() {
        var _func = 'UNICODE';
        return function (buffer, index, depth) {
            if (typeof depth === "undefined") { depth = 0; }
            _trace(_func, depth, true);
            var r;

            if (index < buffer.length) {
                r = R.ok(paka.P.UNICODE, index, 1, null);
            } else {
                r = R.error(paka.P.UNICODE, index, null, 'Expects a unicode character');
            }

            paka.S.ERROR == r.status && _update_last_error(r);
            _trace(_func, depth, false, r.status);
            return r;
        };
    }
1180691
def cjkFragSplit(frags, maxWidths, calcBounds, encoding='utf8'):
    

    from reportlab.rl_config import _FUZZ

    U = []  # get a list of single glyphs with their widths etc etc
    for f in frags:
        text = f.text
        if not isinstance(text, unicode):
            text = text.decode(encoding)
        if text:
            U.extend([cjkU(t, f, encoding) for t in text])
        else:
            U.append(cjkU(text, f, encoding))

    lines = []
    widthUsed = lineStartPos = 0
    maxWidth = maxWidths[0]

    for i, u in enumerate(U):
        w = u.width
        widthUsed += w
        lineBreak = hasattr(u.frag, 'lineBreak')
        endLine = (widthUsed > maxWidth + _FUZZ and widthUsed > 0) or lineBreak
        if endLine:
            if lineBreak: continue
            extraSpace = maxWidth - widthUsed + w
            #This is the most important of the Japanese typography rules.
            #if next character cannot start a line, wrap it up to this line so it hangs
            #in the right margin. We won't do two or more though - that's unlikely and
            #would result in growing ugliness.
            nextChar = U[i]
            if nextChar in ALL_CANNOT_START:
                extraSpace -= w
                i += 1
            lines.append(makeCJKParaLine(U[lineStartPos:i], extraSpace, calcBounds))
            try:
                maxWidth = maxWidths[len(lines)]
            except IndexError:
                maxWidth = maxWidths[-1]  # use the last one

            lineStartPos = i
            widthUsed = w
            i -= 1
        #any characters left?
    if widthUsed > 0:
        lines.append(makeCJKParaLine(U[lineStartPos:], maxWidth - widthUsed, calcBounds))

    return ParaLines(kind=1, lines=lines)
1213666
def ascii_mode(enabled=True):
    
    global _backups, _chars, _primary_style, _secondary_style, _ascii_mode
    if not (enabled or _backups) or (enabled and _ascii_mode):
        return
    if enabled:
        _backups = _chars.copy(), _primary_style, _secondary_style
        _chars = {
            "primary": {"selected": "*", "block": "#"},
            "secondary": {"arrow": ">", "left-edge": "|", "right-edge": "|"},
            "plain": {"unselected": "."},
        }
        _primary_style = ()
        _secondary_style = ()
    else:
        _chars, _primary_style, _secondary_style = _backups
    _ascii_mode = enabled
44632
def edges(word: str, lang: str = "th"):
    

    obj = requests.get(f"http://api.conceptnet.io/c/{lang}/{word}").json()
    return obj["edges"]