Draws a vertical bar made of unicode characters.

    :param value: A value between 0 and 100
    :param width: How many characters wide the bar should be.
    :returns: Bar as a String
188828
def make_vertical_bar(percentage, width=1):
    
    bar = ' _▁▂▃▄▅▆▇█'
    percentage //= 10
    percentage = int(percentage)
    if percentage < 0:
        output = bar[0]
    elif percentage >= len(bar):
        output = bar[-1]
    else:
        output = bar[percentage]
    return output * width
737269
def to_unicode(value):
    
    if isinstance(value, _TO_UNICODE_TYPES):
        return value
    if not isinstance(value, bytes):
        raise TypeError(
            "Expected bytes, unicode, or None; got %r" % type(value))
    return value.decode("utf-8")
285689
def to_unicode(value):
    
    if isinstance(value, _TO_UNICODE_TYPES):
        return value
    if not isinstance(value, bytes_type):
        raise TypeError(
            "Expected bytes, unicode, or None; got %r" % type(value)
        )
    return value.decode("utf-8")
456753
def draw(self, value, newline=True, flush=True):
        
        # This is essentially winch-handling without having
        #   to do winch-handling; cleanly redrawing on winch is difficult
        #   and out of the intended scope of this class; we *can*
        #   however, adjust the next draw to be proper by re-measuring
        #   the terminal since the code is mostly written dynamically
        #   and many attributes and dynamically calculated properties.
        self._measure_terminal()
        
        # To avoid zero division, set amount_complete to 100% if max_value has been stupidly set to 0
        amount_complete = 1.0 if self.max_value == 0 else value / self.max_value
        fill_amount = int(floor(amount_complete * self.max_width))
        empty_amount = self.max_width - fill_amount

        # e.g., '10/20' if 'fraction' or '50%' if 'percentage'
        amount_complete_str = (
            u"{}/{}".format(value, self.max_value)
            if self._num_rep == "fraction" else
            u"{}%".format(int(floor(amount_complete * 100)))
        )

        # Write title if supposed to be above
        if self._title_pos == "above":
            title_str = u"{}{}\n".format(
                " " * self._indent,
                self.title,
            )
            self._write(title_str, ignore_overflow=True)

        # Construct just the progress bar
        bar_str = u''.join([
            u(self.filled(self._filled_char * fill_amount)),
            u(self.empty(self._empty_char * empty_amount)),
        ])
        # Wrap with start and end character
        bar_str = u"{}{}{}".format(self.start_char, bar_str, self.end_char)
        # Add on title if supposed to be on left or right
        if self._title_pos == "left":
            bar_str = u"{} {}".format(self.title, bar_str)
        elif self._title_pos == "right":
            bar_str = u"{} {}".format(bar_str, self.title)
        # Add indent
        bar_str = u''.join([" " * self._indent, bar_str])
        # Add complete percentage or fraction
        bar_str = u"{} {}".format(bar_str, amount_complete_str)
        # Set back to normal after printing
        bar_str = u"{}{}".format(bar_str, self.term.normal)
        # Finally, write the completed bar_str
        self._write(bar_str, s_length=self.full_line_width)

        # Write title if supposed to be below
        if self._title_pos == "below":
            title_str = u"\n{}{}".format(
                " " * self._indent,
                self.title,
            )
            self._write(title_str, ignore_overflow=True)

        # Newline to wrap up
        if newline:
            self.cursor.newline()
        if flush:
            self.cursor.flush()
669151
def add_vertical(str, value)
      node = nil
      str.each_char { |c|
        if (node == nil)
          node = self.add_horizontal_char(c)
        elsif (node.down != nil)
          node = node.down.add_horizontal_char(c)
        else
          node.down = Node.new(c, node)
          node = node.down
        end
      }
      node.value = value
    end
408942
def string_width(string, font_size)
      font_scale = font_size / 10.0
      string.count(Worksheet::THIN_CHARS) * font_scale
    end
612657
def to_unicode(value):
  
  if isinstance(value, str):
    return value.decode('utf-8')

  assert isinstance(value, unicode)
  return value
266440
def render_unicode(self, *args, **data):
        """"""

        return runtime._render(self,
                                self.callable_,
                                args,
                                data,
                                as_unicode=True)
331210
function width (val) {
  var cr = val.indexOf(EOL);
  if (cr !== -1) {
    val = val.substring(0, cr);
  }
  if (typeof val !== 'string') {
    val = val + '';
  }
  var h = val.match(/[ -~]/g);
  return val.length * 2 - (h ? h.length : 0);
}
28924
def string_width(word: str) -> int:
    
    return sum(map(lambda x: 2 if east_asian_width(x) in 'FWA' else 1, word))
375365
def wrap(self, string, width):
        
        if not string or width <= 0:
            logging.error("invalid string: %s or width: %s" % (string, width))
            return False

        tmp = ""
        for line in string.splitlines():
            if len(line) <= width:
                tmp += line + "\n"
                continue

            cur = 0
            length = len(line)
            while cur + width < length:
                cur = line[:cur+width].rfind(self.sep) + len(self.sep) - 1
                line = line[:cur] + "\n" + line[cur+1:]

            tmp += line + "\n\n"

        return tmp
232162
def width
      string = to_s
      max_width = 0
      string.each_line do |line|
        max_width = [max_width, line.uncolored.chomp.size].max
      end
      max_width
    end
171047
def pattern(self, value):
        

        if value is not None:
            assert type(value) in (unicode, QString), \
                "'{0}' attribute: '{1}' type is not 'unicode' or 'QString'!".format("pattern", value)
        self.__pattern = value
393303
def wrap(s, width=80):
    
    return '\n'.join(textwrap.wrap(str(s), width=width))
874354
def pretty_value(value, starting_col = 0, indent_wrapped_lines = 6, width = Terminal.width)
      # inspected = value.inspect

      # note that if the first line overflows due to the starting column then pp won't wrap it right
      inspected = PP.pp(value, "", width - starting_col).chomp

      # this bit might be redundant with the pp call now
      indented = indent_all(6, inspected)
      if width
        wrap_and_indent(indented, starting_col, indent_wrapped_lines, width)
      else
        indented
      end
    end
766880
def StringV(value, length=None, **kwargs):
    

    if length is None:
        length = len(value)

    if length < len(value):
        raise ValueError("Can't make a concrete string value longer than the specified length!")

    result = String("StringV", (value, len(value)), length=length, **kwargs)
    return result
1128798
def stroke_width(value):
        
        if value.value:
            _assert_is_type('stroke_width.value', value.value, int)
            if value.value < 0:
                raise ValueError('stroke width cannot be negative')