code: def _decode_codepage(codepage, data):
      
  
      assert isinstance(data, bytes)
  
      if not data:
          return u""
  
      # get the required buffer length first
      length = winapi.MultiByteToWideChar(codepage, 0, data, len(data), None, 0)
      if length == 0:
          raise ctypes.WinError()
  
      # now decode
      buf = ctypes.create_unicode_buffer(length)
      length = winapi.MultiByteToWideChar(
          codepage, 0, data, len(data), buf, length)
      if length == 0:
          raise ctypes.WinError()
  
      return buf[:]
docs: Args:
          codepage (int)
          data (bytes)
      Returns:
          `text`
  
      Decodes data using the given codepage. If some data can't be decoded
      using the codepage it will not fail.