go/go-encode-id.cc
std::string
go_mangle_struct_tag(const std::string& tag)
{
  std::string ret;
  const char* p = tag.c_str();
  const char* pend = p + tag.length();
  while (p < pend)
    {
      unsigned int c;
      size_t len = fetch_utf8_char(p, &c);
      if (len > 1)
	ret.append(p, len);
      else if (!char_needs_encoding(c) && c != '.')
	ret += c;
      else
	{
	  char buf[16];
	  snprintf(buf, sizeof buf, ".x%02x", c);
	  ret += buf;
	}
      p += len;
    }
  return ret;
}
// Encode a struct field tag.  This is only used when we need to
// create a type descriptor for an anonymous struct type with field
// tags.  This mangling is applied before go_encode_id.  We skip
// alphanumerics and underscore, replace every other single byte
// character with .xNN, and leave larger UTF-8 characters for
// go_encode_id.
Encode a struct field tag.  This is only used when we need to
create a type descriptor for an anonymous struct type with field
tags.  This mangling is applied before go_encode_id.  We skip
alphanumerics and underscore, replace every other single byte
character with .xNN, and leave larger UTF-8 characters for
go_encode_id.
Encode a struct field tag . This is only used when we need to create a type descriptor for an anonymous struct type with field tags . This mangling is applied before go_encode_id . We skip alphanumerics and underscore replace every other single byte character with . xNN and leave larger UTF - 8 characters for go_encode_id .
std::string
go_mangle_struct_tag(const std::string& tag)
{
  std::string ret;
  const char* p = tag.c_str();
  const char* pend = p + tag.length();
  while (p < pend)
    {
      unsigned int c;
      size_t len = fetch_utf8_char(p, &c);
      if (len > 1)
	ret.append(p, len);
      else if (!char_needs_encoding(c) && c != '.')
	ret += c;
      else
	{
	  char buf[16];
	  snprintf(buf, sizeof buf, ".x%02x", c);
	  ret += buf;
	}
      p += len;
    }
  return ret;
}
std :: string go_mangle_struct_tag ( const std :: string & tag ) { std :: string ret ; const char * p = tag . c_str ( ) ; const char * pend = p + tag . length ( ) ; while ( p < pend ) { unsigned int c ; size_t len = fetch_utf8_char ( p , & c ) ; if ( len > 1 ) ret . append ( p , len ) ; else if ( ! char_needs_encoding ( c ) && c != ' ' ) ret += c ; else { char buf [ 16 ] ; snprintf ( buf , sizeof buf , " " , c ) ; ret += buf ; } p += len ; } return ret ; }
Encode a struct field tag.
Encode a struct field tag .