FindLabelEnd

PWCHAR __stdcall FindLabelEnd(PWCHAR pBegin, PWCHAR pEnd, UINT8 bAllowEmail){
  PWCHAR result; 
  if( bAllowEmail )
  {
    for( result = pEnd - 1; result >= pBegin; --result )
    {
      if( *result == 64 )
        return result;
    }
  }
  else
  {
    while( pBegin < pEnd )
    {
      if( *pBegin == 46 )
        return pBegin;
      ++pBegin;
    }
  }
  return pEnd;
}

Referenced by:

punycode_decode
punycode_encode